Value pushed into tracks array into the property 5439 is not visible in the output

Tell us what’s happening:

Hello, when i execute my code and submit it, the system says that the solution is correct. But when i check my output of my code, value pushed into tracks array into the property 5439 is not visible in the output.

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(prop !== "tracks" && value !== "") {
  collection[id][prop] = value;
else if(prop === "tracks" && collection[id][prop] === undefined ) {
  collection[id][prop] = [];
else if(prop === "tracks" && value !== "") {
else if(value === ""){
  delete collection[id][prop];

  return collection;


updateRecords(5439, "tracks", "Take a chance on me");

//The following is my output:
//'5439': { album: 'ABBA Gold', tracks: [] } }

Your browser information:

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

Challenge: Record Collection

Link to the challenge:

I think it’s just because of how the test was written. It pops the array and checks the string that gets returned. So if you run the tests by the end when you console.log the object it does not have the string in the array (same with 1245 object).

assert(updateRecords(5439, "tracks", "Take a Chance on Me")[5439]["tracks"].pop() === "Take a Chance on Me");

If you do not run the tests you can see the array content.

thank you for your reply. Oh so you mean that there is nothing wrong with my code? Also when i copy pasted the solution from the forum it works fine. It even worked with the solution posted by some student. But it didn’t work for me . After finished writing my code, when i tried to submit the code, it showed me that it failed to execute some tests successfully. So when i manually did the tests which it highlighted, my solution code got accepted, but failed to the show the array content.

Right, your code is passing the tests.

It is just when you log the object after all the tests have run the object does not look as expected because of how the tests are mutating the object.

1 Like

oh ok. Thank you. :slightly_smiling_face: :slightly_smiling_face: