Basic JavaScript - Record Collection

Tell us what’s happening:
Describe your issue in detail here.

Your code so far

// Setup
const recordCollection = {
  2548: {
    albumTitle: 'Slippery When Wet',
    artist: 'Bon Jovi',
    tracks: ['Let It Rock', 'You Give Love a Bad Name']
  },
  2468: {
    albumTitle: '1999',
    artist: 'Prince',
    tracks: ['1999', 'Little Red Corvette']
  },
  1245: {
    artist: 'Robert Palmer',
    tracks: []
  },
  5439: {
    albumTitle: 'ABBA Gold'
  }
};

// Only change code below this line
function updateRecords(records, id, prop, value) {
  return records;
}

updateRecords(recordCollection, 5439, 'artist', 'ABBA');

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Record Collection

Link to the challenge:

Hello and welcome to the community :smiley:!
You should describe what issue you are facing between the *** marks at the top of your post.
You basically want to make some changes to your object based on the arguments that get passed onto your function.
Use either an if/else statement or count to check that the conditions of the arguments that are passed are given the right action.
Don’t stress if its hard because this step is really tough. I’ve spent a while on it already and have still yet to pass so good luck!
Don’t hesitate to ask for help if your stuck!
Have a :confetti_ball: :tada: :confetti_ball: time coding!!!

2 Likes

Tell us what’s happening:
Describe your issue in detail here.

Your code so far

// Setup
const recordCollection = {
  2548: {
    albumTitle: 'Slippery When Wet',
    artist: 'Bon Jovi',
    tracks: ['Let It Rock', 'You Give Love a Bad Name']
  },
  2468: {
    albumTitle: '1999',
    artist: 'Prince',
    tracks: ['1999', 'Little Red Corvette']
  },
  1245: {
    artist: 'Robert Palmer',
    tracks: []
  },
  5439: {
    albumTitle: 'ABBA Gold'
  }
};

// Only change code below this line
function updateRecords(records, id, prop, value) {
  if( prop== "artist") {
           recordCollection[id][prop] = value
    return recordCollection
  }else if((prop === "tracks"){
    
  }
return records;
}

updateRecords(recordCollection, 5439, 'artist', 'ABBA');

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Record Collection

Link to the challenge:

Please Tell us what’s happening in your own words.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more you say, the more we can help!

2 Likes

Hello!
You seem to be getting there. I haven’t passed this step yet either so I’d love to solve this one 2gether!

The first thing I’ve noticed is the error that popped up in the console window which didn’t allow the code to run:


The error is a syntax error and it shows that there is a missing closing ) bracket after the if statement. That’s because you have two opening (( brackets after your else if statement when only one is necessary. Using the console window to pick up errors can makes the job so much easier.
Now that the code runs you can easily see which conditions still have to be met.
I’m gonna try to solve them now and I’d love to here, how it works out for you.
Happy coding!

Also instead of using specific example you want your function to work for all input s that a user can pass as arguments.
Ex instead of saying:

you can say something like:

if (prop === "")

and then delete the prop property from the album because the argument entered as a value is an empty string.

Instead of using recordCollection as the objects name use the ‘records’ property as the name recordCollection is passed in to equel to ‘recordCollection’ and the step wants you to return records.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.