Help with JS Coding challenge

Tell us what’s happening:
Describe your issue in detail here.
I don’t know what to do
Your code so far


// Setup
var 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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 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 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.

2 Likes

I’m not sure where to to start or how

Tell us what’s happening:
Describe your issue in detail here.
I don’t know where to start or how
Your code so far


// Setup
var 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 == )
return records;
}

updateRecords(recordCollection, 5439, 'artist', 'ABBA');
  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36.

Challenge: Record Collection

Link to the challenge:

The challenge lists several different possibly situations. Why not start by writing if/else statements for each of those situations. Then you can add the logic to each block one at a time.

I tryed by doing

// Setup
var 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)
  return records;
}

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

That’s one if. Currently the problem with it is that you have tracks instead of "tracks" so it is looking for a variable named tracks instead of comparing to the string “tracks”.

Sorry I wasnt getting any responces

Oh thank you so much ill try that now

I’VE gotten that so whats next

Write the rest of your if/else statements.

Not sure what i should put but this what what i tried

function updateRecords(records, id, prop, value) {
  if (prop ==  "tracks") {
    return recordCollection.["id"].["prop"]
  }
  return records;
}
  1. Why do you only have one if/else statement?

  2. Why are you mixing dot and bracket notation? That syntax is not valid.

  3. Why are you returning that value?

  4. Why are you referencing the global variable holding the sample object?

1 Like

I’m really sorry i honestly don’t know what to do

Did you maybe jump ahead in the curriculum by accident? It looks like you want to review some of the earlier lessons about if/else statements, global variables, and accessing object properties.

1 Like

No I just have really bad memory

Then it’s probably a good idea to review the fundamentals. Lot’s of learning to code is done through repetition, so take as long as you need to in order to understand.

1 Like

Ok i will come back to you a few days later after revising over what I’ve learned
Thank you so much

Should I use a

.unshift

I don’t see any way that unshift() would be useful here.