Problems with the "Record Collection" exercise

Hi everyone, I hope you are all doing well.

I’d like to ask some help with this exercise from the Basic JavaScript course. We are supposed to change the updateRecords function so as to make changes in the collection object. When I run the tests, I get this message

After updateRecords(collection, 2468, "tracks", "Free") , tracks should have the string 1999 as the first element.

I don’t understand why I’m getting this, all the other tests are running ok. This started to happen after I decided to delete this line from all the if statements, to get a cleaner code:

&& prop === “tracks”

The code so far

// Setup
var collection = {
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(object, id, prop, value) {
if (prop !== "tracks" && value !== "") {
  object[id][prop] = value;
} else if (value === "") {
  delete object[id][prop];
} else if (value !== "" && object.hasOwnProperty("tracks") === true) {
} else {
  object[id][prop] = [value];
return object;

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

I would appreciate it if someone could lend me a hand on this :slight_smile: Thank you for your attention!

Challenge: Record Collection

Link to the challenge:

I think you’re missing an [i]

You can simplify you logical checks a bit once you fix that bug.

1 Like

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