Record Collection review

Record Collection review
0.0 0

#1

Tell us what’s happening:

Hi there,

Please i’ll like to know where within my code which doesn’t make the code to solve the challange. Especially with this “After updateRecords(2548, “artist”, “”), artist should not be set”. I don’t seem to get it.

Thanks very much!

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"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
  collection["5439"].artist = "ABBA";
  var track = collection["5439"].tracks = [];
  track.push("Take a Chance on Me");

  collection["1245"].album = "Riptide";
  collection["1245"].tracks.push("Addicted to Love");

  collection["2548"].artist = "";


  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/record-collection


#2

You appear to just be trying to hardcode the test results. The whole point is that the function’s behavior should be controlled by the arguments. Every test should result in a different collection.


#3

Okay, please so what can i do to make it work?


#4

You should have been writing functions that used argument variables prior to this. You need to do the same thing here.


#5

i thought a function was already provided. If so, then help me to understand.

Thanks!


#6

What do you mean “a function was already provided”? They created the function declaration for you. You need to make it work. You need to make it work by using the arguments which are passed to it as the variables id, prop, and value. You should have been solving challenges that required you to do this already.