Build a Record Collection - Build a Record Collection

Tell us what’s happening:

Hello, I just dont why step 3 wont pass. I`ve tried everything I understand. Any help would be greatly appreciated

Your code so far

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

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

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

  return records
}

console.log(updateRecords(recordCollection, 5439, "artist", "ABBA"))

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36 Edg/148.0.0.0

Challenge Information:

Build a Record Collection - Build a Record Collection

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-record-collection/56533eb9ac21ba0edf2244cf.md at main · freeCodeCamp/freeCodeCamp · GitHub

Welcome to the forum @samueloghali,

You have created an array for tracks, but you forgot to push() the value to it.

Happy coding

Thank you, that helped. But I think something is missing in the last else/if

If you need more help, please post your updated code.

I already passed it. Thanks