Can someone help me?, I'm so lost

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!==tracks&&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/96.0.4664.110 Safari/537.36

Challenge: Record Collection

Link to the challenge:

Hello there.

Do you have a question?

If so, please edit your post to include it in the Tell us what’s happening section.

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

Also, the more information you give us, the more likely we are to be able to help.


It looks like you haven’t done very much yet. What parts are confusing you?

1 Like

Hello ,
The instructions are so confusing.

Ok, which parts are confusing you? Which parts do you understand?

Everything I guess, from what I read I have to make an if statement, but why though and why there is no video explaining the assignment?

Before jumping to syntax it is important to understand the task.


Here is the problem description:

  • Your function must always return the entire record collection object.
  • If prop isn’t tracks and value isn’t an empty string, update or set that album’s prop to value .
  • If prop is tracks but the album doesn’t have a tracks property, create an empty array and add value to it.
  • If prop is tracks and value isn’t an empty string, add value to the end of the album’s existing tracks array.
  • If value is an empty string, delete the given prop property from the album.

There are a lot of highlighted terms in there. So, I think the first big task is to understand what all of these inputs are.

Here is the function signature:

function updateRecords(records, id, prop, value)

Here is a sample function call:

updateRecords(recordCollection, 5439, "artist", "ABBA")
//           (records,          id,   prop,      value)
  • What does the argument records mean?

  • What does the argument id mean?

  • What does the argument prop mean?

  • What does the argument value mean?


I don’t think a video walkthrough would be a good idea for this challenge. At some point, learners need to develop the ability to start developing their own plan to handle complex tasks. Video walkthroughs get in the way of that.

1 Like
This is what I got so far, still not working.

// 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(recordCollection, id, prop, value) {

if(prop !=='tracks' && value!=="" ){

recordCollection[id][prop] = value;

}else if(prop =='tracks' && id!== 'tracks'){

recordCollection[id]['tracks'] = [];

recordCollection[id][prop].push(value);

}else if(prop =='tracks' && value!==""){

recordCollection[id][prop].push(value);

}else if(value ==""){

delete recordCollection[id][prop];

}

return recordCollection;

}

// Alter values below to test your code

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

updateRecords(recordCollection, 2468, "tracks", "Free");

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

I don’t think this means what you think this means. What do you think this is doing?


You should never directly reference this variable in your function.

What do you mean I You should never directly reference this variable in my function.

I mean you should never inside of your function write recordCollection. Absolutely nowhere.

I have a question are you a bot or a real person?

I’m totally a real human. 0% robot, or so I believe.

lol, are you active 24/7 because your replies are so fast.

Haha, I’m waiting for the test suite on some code I’m working on to finish up.

Interesting!, so going back to the code what do I need to change.

//My Code
// 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(recordCollection, id, prop, value) {
if(prop !=='tracks' && value!=="" ){
recordCollection[id][prop] = value;
return recordCollection;
}else if(prop =='tracks' && id!== 'tracks'){
recordCollection[id]['tracks'] = [];
recordCollection[id][prop].push(value);
return recordCollection;
}else if(prop =='tracks' && value!==""){
recordCollection[id][prop].push(value);
return recordCollection;
}else if(value ==""){
delete recordCollection[id][prop];
return recordCollection;
}


}

// Alter values below to test your code
updateRecords(recordCollection, 5439, "artist", "ABBA");
I don't know what to do with the"( id!=='tracks')".
function updateRecords(records, id, prop, value) {

Why change the function signature?


What do you want id!=='tracks' to be doing for you?

what you mean function signature? you mean the records thing?
id!==‘tracks’ means the album doesn’t have a tracks property.

Your code says:
function updateRecords(recordCollection, id, prop, value) {
Your code should say:
function updateRecords(records, id, prop, value) {

Why did you change it?


id!=='tracks' means that the value stored in the variable id is not the same thing as the string 'tracks'.