Basic JavaScript - Record Collection

Tell us what’s happening:
No idea what’s going on, feel like I was used to beating level 2 bosses then got mauled by the bear from revenant. Plz Halp.

Your code so far

// 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 (value === "") {
    delete updateRecords[2];
  } else if (prop !== "tracks"); {
    recordCollection[prop].push(value);
  } else if (prop == "tracks");
    recordCollection[prop].push(value);
  if (tracks ==="");
    recordCollection == [] || [prop].push(tracks);
  return records;
}

updateRecords(recordCollection, 5439, 'artist', 'ABBA');

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Record Collection

Link to the challenge:

You have to follow the given rules, for example:
2. “If value is an empty string, delete the given prop property from the album.” The first argument in the function “updateRecords” (named ‘records’) is actually “recordCollection”. You can see that from the function call given in the challenge:

updateRecords(recordCollection, 5439, 'artist', 'ABBA');

So, to delete records whose property doesn’t have a value, you should delete records with the concrete id, and prop that has no value:

delete records[id][prop]

For example, if you have a record 6666: {albumTitle: ""} within recordCollection, the output will be: 6666: {}, because the value for the prop ‘albumTitle’ is empty, and that property will be deleted.

Try to follow the given rules one by one in this challenge and break them into small, self-explanatory steps.

I hope this helps a little bit at least.

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