JavaScript Algorithms and Data Structures - RECORD COLLECTION

Tell us what’s happening:
I am only getting one to pass. I have seen this problem worked out before. So there are two parts to this. Validate the existing info and then allowing new info to be added to then update the Record Collection.

However, I am not sure of myself. The syntax is correct, yet what I’ve asked for is not doing anything. Plus, I believe that I should in some way be able to simplify the conditional statement better. But, I’m not fluid enough for that.

I need to understand exactly the what and why of the word problem, please.

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 (id === id) {
      return records;
  } else if (prop != tracks && value != "") {
      return prop.hasOwnProp(value);
  } else if (prop == tracks && tracks == "") {
      return tracks + value;
  } else if (prop == tracks && value != "") {
      return tracks.push(value);
  } else if (value == "") {
      return id - prop;
  } else {
      return recordCollection;

updateRecords(recordCollection, 5439, 'artist', 'ABBA');
type or paste code here

Your code so far

What is this check doing? I suspect it doesn’t do what you intend

It really helps if you use the Ask For Help button o the challenge you are working on. The mixed code is a bit confusing.

Hey JeremyLT,

I was slowly reading the word problem. I just went through the first time and ignored the “id” argument. So, I thought maybe I should add it in to check to verify it was there.

I’m trying, yet I’m not sure of myself.

I would back up and determine what the function arguments are

I am a very literal person when learning new things. I’m guessing not everything I was given in the Object Literal is needed to solve this problem. Might I just need these arguments (id, prop, value) ?

You also need ‘records’.

Programming is all about being literal. You should replicate the literal technical meaning of each part of the instructions. Turning words into literal technical meaning is hard though.

Smh, JeremyLT, you ain’t neva lie! LOL…

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