Build a Record Collection - Build a Record Collection

Tell us what’s happening:

I am stuck on this exercice, i don’t understand why 3 is not passing

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] = [];
    records[id][prop].push(value);
  } else if(prop === "tracks" && value !== "") {
    records[id][prop].push(value);
  }
  return records; 
};


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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0.1 Safari/605.1.15

Challenge Information:

Build a Record Collection - Build a Record Collection

don’t you see this error “TypeError: Cannot read properties of undefined (reading ‘push’)” with your code?

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