Im stuck..i need help

okay…so after modifying the functions according to the rules given,the code is still not running…So my question is how do i push and unshift the additional tracks listed in the challenge


// 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; rv:94.0) Gecko/20100101 Firefox/94.0

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.

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;
}

I formatted your code so that it is possible for others to read it more easily.

1 Like

okay…so after modifying the functions according to the rules given,the code is still not running…So my question is how do i push and unshift the additional tracks listed in the challenge

This looks suspicious to me.

1 Like

Hi @atibsjohn !

The good news is that you figured out the hardest parts of this challenge.
Once you fix that small error that was pointed out to you, then it will pass.

So i finally figured it out…problem was my structure,.