Help with JavaScript certification exercise

Tell us what’s happening:
Hello, good afternoon …
I am trying to perform this JavaScript certification exercise in which I have a list of objects in which the first thing I do is check that the field to change is different from tracks (that is, artist) and that the value is not null , otherwise if it is tracks then I verify that this field exists in the list in order to create an empty arrangement referring to it and with its value, then it is verified that value is not an empty string and I insert it at the end of the list , and if it is empty, this property is eliminated. I think I must have the error in the empty arrangement … I don’t know … it’s where I more or less feel lost
Your code so far

var collection = {
  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'
  }
};
function updateRecords(object, id, prop, value) {

  if (prop!=='tracks' && value!=="") {
    object[id][prop]=value;
  } else if (prop==="tracks" && object[id].hasOwnProperty("tracks")==="false") {
    object[id][prop]=[value];  
  } else if (prop==="tracks" && value!=="" && object[id][prop].hasOwnProperty) {
      object[id][prop].push(value);
  } else if (value==="") {
      delete object[id][prop];
  }
  return object;
}

please when you ask for help always include the challenge link

The order of your if clauses is causing you trouble

what is this?
I get error that you can’t get hasOwnProperty of undefined when I test the failed test function call

Thank you very much to all I already solved it … there was a syntax error in the evaluation of hasOwnProperty and its value

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.