Basic JavaScript - Record Collection

Tell us what’s happening:
Describe your issue in detail here.
Can you help, please.
Looks like im stack on the last challenge.
After I put delete record [id][prop] have result: ```
updateRecords(recordCollection, 2548, “tracks”, “”)



should not be set // tests completed.

Meny thanks.

**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(prop!=="tracks" && value!==""){
   records[id][prop]= value;
  }else if(prop==="tracks"){
  }else {
   delete records[id][prop];
  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/605.1.15 (KHTML, like Gecko) Version/15.6.1 Safari/605.1.15

Challenge: Basic JavaScript - Record Collection

Link to the challenge:

For that test, your current code ends up adding an empty string element to the end of the existing tracks property. Instead, there should be no tracks property at all per the following instruction:

  • If value is an empty string, delete the given prop property from the album.

Thank you very much. Did put:
else if(val===“”){
delete records[id][prop];
still have same problem.
Should I set prop first,then delete it?
Sorry if it sound silly, run out of ideas.


You need to go line by line with your call to updateRecords(recordCollection, 2548, "tracks", "") and understand why your function is adding an empty string to the tracks array for the 2548 album.

The first if statement would be false, so the else if condition gets checked. Since prop is "tracks", the else if` code block gets executed.

You either need to rethink the order of your if, else if, and else statements to fix your existing code.

Thank you so much.
I did change stack of orders and it is working !
Very appreciate your help.