Why records? Not recordCollection

I copy-pasted the first task so I can know how it works but my previous syntax is

if (prop !== “tracks” && value !== “”) {recordCollection[id][prop] = value;}

shouldn’t we change what’s inside recordcolletion ? since it is the only variable I see, not the record.

Pardon my stupidity :smiley: just learn js for two weeks now.
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(recordCollection, id, prop, value) {
if (prop !== "tracks" && value !== "") {
}  // I don't know how to fill the curled nest, help!

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/94.0.4606.81 Safari/537.36 OPR/80.0.4170.63

Challenge: Record Collection

Link to the challenge:

If you are asking why starting code has records in:

function updateRecords(records, id, prop, value) {

That’s because function should change object that is passed as first argument to the function. That way function doesn’t depend on any variable that’s outside of function scope - like globally defined recordCollection.


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