Basic JavaScript - Record Collection

Tell us what’s happening:
Describe your issue in detail here.
I don’t know where I went wrong in this code. Please send me the right code or point out where i am wrong

  **Your code so far**
// Setup
const recordCollection = {
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 updateRecordsid, prop, value) {
var album = recordCollection[id];
if( prop!= "tracks" && value != ""){
  value = recordCollection[id][prop];  
}else if(prop = "tracks" && !recordCollection[id].hasOwnProperty("tracks") ){
  var tracks = [];
  tracks.push(value);
  recordCollection[id][prop] = tracks;
}else if(prop = tracks && value != ''){
  recordCollection[id][prop].push(value);
}else{
  delete recordCollection[id][prop];
}
return records;
}

updateRecords(recordCollection, 5439, 'tracks', 'tests');
console.log(recordCollection);
  **Your browser information:**

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

Challenge: Basic JavaScript - Record Collection

Link to the challenge:

Hi

We don’t do this here.

some syntax is wrong here

First, wrong syntax, this is not how a function signature should look like. You should have an updateRecords function that accepts 4 parameters.

You should also only reference those 4 parameters, not global variables

1 Like

<SOLUTION REDACTED by mod>

Hey @chinude080 , It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

1 Like
  • // Only change code below this line
    function updateRecordsid, prop, value) {

you forgot to add a bracket after updateRecords .

  • if( prop!= “tracks” && value != “”){
    value = recordCollection[id][prop];

''change the recordCollection to records, because you have to use the function parameters"
" value should be after the assignment operator"