Record collection.....2 case failing

// Setup

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'



// Only change code below this line

function updateRecords(object, id, prop, value) {

  if(prop!=="tracks" && value!==""){



  else if(prop==="tracks" && object[id].hasOwnProperty(prop)==false){



  else if(prop==="tracks" && value!==""){



  else if(value==="" &&object[id].hasOwnProperty(prop)==true){

    delete  object[id][prop];


  return object;


updateRecords(collection, 5439, 'artist', 'ABBA');

Can anyone say the error in this plz??
struck up with 2 cases:
After updateRecords(collection, 1245, "tracks", "Addicted to Love") , tracks should have the string Addicted to Love as the last element.

After updateRecords(collection, 2468, "tracks", "Free") , tracks should have the string 1999 as the first element.

Can u plz explain the how the object works too

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

I suspect that you have a problem here. If the object does not have the property prop, then object[id][prop] is undefined and push() is not a valid method for undefined.

Also, here you have objects instead of object.

thanks a lot…My test cases passed

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