Record Collection ..__

Tell us what’s happening:
How do i set the value for the record albums property.

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) {
  if (prop !== "tracks" && value !== "") {
    
  }
  
  return collection;
}

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

Your browser information:

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 11151.113.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.127 Safari/537.36.

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

1 Like

From MDN Web Docs:

You can define a property by assigning it a value.

Say you’re a car collector and you’re building an organizing app to manage information about your still small collection. For now, your collection looks like this:

var cars = {
  "car1": {
    "make": "Toyota",
    "model": "Prius",
    "year": 2010
  },
  "car2": {
    "make": "Honda"
  }
}

car1 has 3 defined properties and corresponding values. car2 has only one property defined. We’d like to define, say, the ‘model’ property by assigning it a value.

cars["car2"].model = "Civic";

and if we check out what our car2 object looks like now:

console.log(cars["car2"]);

in the console, we see

{ make: 'Honda', model: 'Civic' }
2 Likes