Basic JavaScript - Record Collection

Tell us what’s happening:
Describe your issue in detail here.
This requirement is not being fulfilled no matter what I try:
" After updateRecords(recordCollection, 5439, "tracks", "Take a Chance on Me") , tracks should have the string Take a Chance on Me as the last and only element. "
I am a newer beginner and cannot figure this out. I’ve done google searches and even watched a YouTube video by Coding David. I cannot figure out what I am doing wrong. It is probably something very simple that I am over-looking, but I cannot find the problem!
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 !== "") {
    records[id][prop] = value;
  } else if (prop === "tracks" && records[id].hasOwnProperty("tracks") === false) {
    records[id][prop] === [value];
  } else if (prop === "tracks" && value !== "") {
    records[id][prop].push(value);
  } else if (value === "") {
    delete records[id][prop];
  }
  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/107.0.0.0 Safari/537.36 Edg/107.0.1418.62

Challenge: Basic JavaScript - Record Collection

Link to the challenge:

What does this line do?

accessing the album in order to modify it.

How are you modifying it?

sorry, wrong one. that was working with the tracks.

And also, sorry for wasting you time… there is only supposed to be one = sign. My code passes now with this.

records[id][prop] = [value];

Thank you though!

I’m not sure I fully understand why this worked though. Can you explain it?

Which part don’t you understand?

= is assignment while === is comparison

Sorry, :man_facepalming:
I don’t know how I forgot. I took a 2 day break… probably should go redo lessons to make sure I have it down.

We all forget stuff - that’s why programmers invented documentation and Google, lol

1 Like

:sweat_smile:
Thank you for explaining that!

1 Like

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