Hi, I solved the “record collection” exercise in JavaScript lessons, but it doesn’t work in the second test (see picture).
I looked for solutions to find the bug, but my solution seems to be identical to all the others…I can’t understand what’s wrong…please help me!
Thanks so much!
// Only change code below this line
function updateRecords(records, id, prop, value) {
if(prop!=='tracks' && value!==""){
records[id][prop]=value;
} else if (prop==='track' && records[id].hasOwnProperty(prop)===false){
records[id][prop]=[];
records[id][prop]= [value];
} else if (prop==='tracks' && value!==""){
records[id][prop].push(value);
} else if (value===""){
delete records[id][prop];
}
return records;
}
