I couldn't find the error in the program .......I tried a lot to get rid of the error

Tell us what’s happening:
Describe your issue in detail here.

   **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!=='tracks' && value!=''){records[id][prop]=value;}

else if(prop=='tracks' && records[id].hasOwnProperty("tracks")==='false'){
 
 records[id]['tracks'].push(value);
 }

else if(prop=='tracks' && value!==''){
 
  records[id][prop].push(value);
  }

else  {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/94.0.4606.61 Safari/537.36

Challenge: Record Collection

Link to the challenge:

the error message is: After

updateRecords(recordCollection, 5439, "tracks", "Take a Chance on Me")

,

tracks

should have the string

Take a Chance on Me

as the last element.

check this carefully, see if you notice something

I observed that n used here to check for the absence of tracks property from the record object. Try to crack the problem by taking a view over the code and the requirements of it.

I tried different logics over the problem. the problem is with the id 5439 which did not has the tracks property predefined.thank u madam.

as I said, check thsi snippet carefully, your issue is here. This will always be false. Why? Figure out why and you can solve it

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