Build a Record Collection - Build a Record Collection

Tell us what’s happening:

So I have tried multiple solutions to no avail, it still fails test 3, 5 and 6… Any suggestions please

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

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36

Challenge Information:

Build a Record Collection - Build a Record Collection

what is prop? can it be the same as records[id]["tracks"]? you are not using a similar comparison anywhere else, consider what comparisons you are using in the other places

here you are creating a new array

is this line going to add a value to that array?

Thanks alot i just needed a change of mindset

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