Record Collection empty test case failing

Tell us what’s happening:
I am writing code for Basic JavaScript: Record Collection
I have almost cleared all the test cases only two are remaining which i dont know some how not working. Below are the two test cases which are failing.

updateRecords(2548, “artist”, “”)
artist should not be set After

updateRecords(2548, “tracks”, “”)
tracks should not be set

Your code so far


// Setup
var collection = {
2548: {
  album: "Slippery When Wet",
  artist: "Bon Jovi",
  tracks: [
    "Let It Rock",
    "You Give Love a Bad Name"
  ]
},
2468: {
  album: "1999",
  artist: "Prince",
  tracks: [
    "1999",
    "Little Red Corvette"
  ]
},
1245: {
  artist: "Robert Palmer",
  tracks: [ ]
},
5439: {
  album: "ABBA Gold"
}
};

// Only change code below this line
function updateRecords(id, prop, value) {
var record = collection[id];
if(prop == "artist" && value == ""){
console.log("do nothing artist");
}else if(prop == "artist" || prop == "album"){
record[prop] = value;
}else if(prop == "tracks" && value !== ""){
var arra = record[prop];
  if(arra == undefined){
    record[prop] = [];
    record[prop].push(value);
  }else{
    arra.push(value);
  }
}else{
console.log("do nothing");
}

return collection;
}

updateRecords(5439, "artist", "ABBA");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36.

Challenge: Record Collection

Link to the challenge:

You are missing the last case from the challenge description

1 Like

it worked, i thought that i need not to do anything if value is empty. I miss interpreted the requirement. Thanks for the help.