Build a Record Collection - Build a Record Collection

Tell us what’s happening:

Hello!

I have tried multiple variations of my code, as well as checked for answers on the forum and I just can’t understand why my code isn’t working. It only passes the first check to have an updateRecords function.

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

const records = recordCollection;

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:147.0) Gecko/20100101 Firefox/147.0

Challenge Information:

Build a Record Collection - Build a Record Collection

Welcome to the forum @muddyevil !

You are using dot notation to access object properties, but that can only be used when you know the exact name of the property like recordCollection.artist. Bracket notation, on the other hand, is much more flexible and allows you to also use a variable or expression.

If you still need help after making those changes, please post your updated code, as follows:

When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add the backticks.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').