Basic JavaScript - Record Collection

Good evening, everyone.

I am starting to lose my mind in this problem in specific. Is it something I’m not doing or something I’m doing wrong? I don’t know… if anyone could help me, I’ll be appreciated. I do not wish to someone to give me the answer, I just want someone to point up to me the direction I must go.

Link for the problem: Basic JavaScript - Record Collection

// 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 (value == records.id.prop.value[""]) {
    delete records.id.prop;
  } 
  else if (prop == records.id.prop["tracks"] && value != records.id.prop.value[""]) {
    records.id.prop.push(value);
  } 
  else if (prop == records.id.prop["tracks"] && records.id.hasOwnProperty[tracks] == False) {
    records.id.prop = [value];
  }
  else if (prop != records.id.prop["tracks"] && value != records.id.prop.value[""]) {
    records.id.prop = value;
  }
  return records;
}

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

You cannot use dot notation with variables holding property names.

So it’ll be something like: records.id.prop[value] == ""?

You are still using dot notation. id is a variable, and prop is a variable. value does not correspond to a property name.

I think I’ll review Arrays and Objects again

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