HELP! I'm drowning in basic JS

Tell us what’s happening:
I can’t seem to figure out what’s wrong with my code.

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: [
     "Little Red Corvette"
 1245: {
   artist: "Robert Palmer",
   tracks: [ ]
 5439: {
   album: "ABBA Gold"

// Only change code below this line
function updateRecords(id, prop, value)
 if(collection[id].hasOwnProperty('tracks')=== false && prop ==='tracks'){
   collection[id][prop] = new Array();
 else if(prop === 'tracks'&& value !== ""){
 else if(collection[id].hasOwnProperty(prop)=== false && value !== ""){
   collection[id][prop] = value;
 else if(value === ""){
   delete collection[id][prop];
 return collection;

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

Your browser information:

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

Challenge: Record Collection

Link to the challenge:

two issues:

  1. in a if/else if/else chain only one of the statements will execute, so if the first statement executed, you just create a new empty array, and then do nothing else

  2. remember that when prop is not “tracks” you need to create or update the property, you are just creating it because if prop is not tracks and the object already has the property you do nothing

1 Like

A thing that might help you out

function     (id,    prop,     value)
updateRecords(5439, "artist", "ABBA");

var collection 
 tracks: ->[]

an empty string"" set to one of those will contain ?
1 Like

I have no idea what KittyKora is trying to show, but ieahleen has zeroed in on your problems.


Thanks a lot this really helped. You also made me realise a couple of concepts that I need to revisit