I can't get past this challenge :(

am stuck guys, HELP!

  **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 updateRecords(records, id, prop, value) {
if(prop !== "tracks" && value !== ""){
  records [id][prop] = value;
else if(prop === "tracks" && records[id].hasOwnProperty["tracks"]){
  records [id][prop] = [value];
else if(prop === "tracks" && value !== ""){
else if(valu ===""){
  delete records[id][prop];
return records;

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

Challenge: Record Collection

Link to the challenge:

The error you get is quite clear: you cannot “push” into an empty object.
You first need to CREATE the array, then you can push.

1 Like

How do we execute a function, like hasOwnProperty?

1 Like

records[id].hasOwnProperty[“tracks”] → The .hasOwnProperty will give u a boolean result “True” or “False”, I think you should specify what answer from it you want in order to excecute the code, talking about the second condition (first Else If), and if the aswer is false then you should create the Tracks array and add value to it, then, u add the -e that u miss at the last condition and you should be done :wink:

1 Like

thank you @Jagaya

i added this statement:

else if (prop === “tracks” && records[id].hasOwnProperty(“tracks”) === false) {
records[id][prop] = [value];

thank you @Sebas_16
challenge SOLVED.

noticed I didn’t specify at first , so I did this instead:

else if (prop === “tracks” && records[id].hasOwnProperty(“tracks”) === false) {
records[id][prop] = [value]; :blush:

1 Like

No I can’t solved this problem.

Hi @Kay21 !

Welcome to the forum!

If you need help with record collection, then please create your own post and people will assist you there.


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