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/118.0.5993.2470 YaBrowser/23.11.0.2470 Yowser/2.5 Safari/537.36

Challenge Information:

Basic JavaScript - Record Collection

// 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',
    tracks: []
  }
};

// Only change code below this line
function updateRecords(records, id, prop, value) {
  if(value===""){
    prop.delete
  }
  else if(prop !== tracks && prop !== value){
    return prop.value
  }
  else if(prop === tracks && value !== ""){
    value.push(recordCollection[3].id[1])
  }
  return records;
}

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

Can anyone explain in detail how to solve this? The creators of this task apparently have no understanding of the training course, since they do not understand that this cannot be done here.

We cannot give you the answer, no.

All of the syntax you need for this step has been covered on previous steps.

If you are more specific about what parts have you stuck, then it will be easier to give you help. At a first look, I suspect you don’t fully understand what each function argument is/does. Can you say what you expect each one to do, in your own words?

2 Likes

I can say with confidence that I studied the previous material well, it’s here that everything is not clear and difficult, this is not a professional approach from the author, I don’t understand why nothing works for me

This is the first step that expects you to do more than copy syntax. Learning how to use syntax to express logical tasks is hard.

Can you give this question a go? What do you understand the function arguments to do?

1 Like

My understanding is that function arguments are the values that are passed there.

Can you say what you think they actually mean? What is ‘id’? What does it mean? Not ‘a number’ but what that number means.

And the rest?

1 Like

ID I think this in the object means it is 2548

Ok, that’s exactly what I asked you not to do, lol.

Id is a number, yes. What is it for? What does it do? 2548 corresponds to what?

id - a number representing a specific album in the records object

The challenge says this. So what does that mean?

1 Like

but here I no longer know where it appears and why this updateRecords variable appeared and why if it appeared somewhere not indicated, there is nothing that is not clear here if you look at it like that.

`updateRecords’ is a function, not a variable.

It’s nearly impossible to do this challenge if you don’t understand what the function arguments mean. That’s why I started asking you if you understand what the arguments mean.

It’s fine that you want to complain, but really all I’m here for is helping people solve the problems.

1 Like

oh yes, this is a function, I got it a little mixed up) function arguments are variables where the function values are added

Right, the arguments represent the values passed into the function. But what can I do with them? Like, how does records and id work together?

  • records - an object containing several individual albums
  • id - a number representing a specific album in the records object

Understanding how these two go together based upon these two lines is really required to do this challenge.

1 Like

I don’t know in detail how they work together, I just assume that in RecordCollection the values ‘artist’, ‘ABBA’ are added to ID 5439

But what is ID 5439?

This says the id represents a specific album. Can you show an example of an individual album inside of the records object?

1 Like

records[1] this is album 2468

No, records[1] would be the album with id 1

1 Like

This { here means that the recordCollection is an object, not an array. Arrays have [ ]

1 Like

records.2468 like this

I wouldn’t use dot notation here since you have variables. Use bracket notation. records[2468]

What is records[2468]?

1 Like

records[id][1 ] like this?