I need help from those smarter i dont know what to do

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**

// Setup
var 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) {
return records;
}

updateRecords(recordCollection, 5439, 'artist', 'ABBA');
  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36.

Challenge: Record Collection

Link to the challenge:

What have you tried? What do you not understand about the instructions?

I’m happy to help, but I am not sure what I should focus on explaining.

I’ve tried this. statements couldn’t find anything for if statements and that’s all i could think of

Can you show us the code you’ve tried? I’m not sure what a ‘this statement’ is?

// Only change code below this line

function updateRecords(records, id, prop, value) {

this.records = records;

this.id = id;

this.prop = prop;

this.value = value;

return records;

}

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

here it is

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

I’m not sure what you are trying to do with this code.


Let’s start at the beginning. What do you think this challenge wants you to do? What parts of the instructions are you not sure about?

You are given an object literal representing a part of your musical album collection. Each album has a unique id number as its key and several other properties. Not all albums have complete information.

You start with an updateRecords function that takes an object literal, records , containing the musical album collection, an id , a prop (like artist or tracks ), and a value . Complete the function using the rules below to modify the object passed to the function.

  • Your function must always return the entire record collection object.
  • If prop isn’t tracks and value isn’t an empty string, update or set that album’s prop to value .
  • If prop is tracks but the album doesn’t have a tracks property, create an empty array and add value to it.
  • If prop is tracks and value isn’t an empty string, add value to the end of the album’s existing tracks array.
  • If value is an empty string, delete the given prop property from the album.

Note: A copy of the recordCollection object is used for the tests.

Run the TestsReset All Code

Get Help

After updateRecords(recordCollection, 5439, "artist", "ABBA") , artist should be the string ABBA

After updateRecords(recordCollection, 5439, "tracks", "Take a Chance on Me") , tracks should have the string Take a Chance on Me as the last element.

After updateRecords(recordCollection, 2548, "artist", "") , artist should not be set

After updateRecords(recordCollection, 1245, "tracks", "Addicted to Love") , tracks should have the string Addicted to Love as the last element.

After updateRecords(recordCollection, 2468, "tracks", "Free") , tracks should have the string 1999 as the first element.

After updateRecords(recordCollection, 2548, "tracks", "") , tracks should not be set

After updateRecords(recordCollection, 1245, "albumTitle", "Riptide") , albumTitle should be the string Riptide
this is it

I think it wants me to make it so that the function switches and/ or makes things in the variable objects

Yes, I can read the instructions. I want to know what your understanding of the instructions is. In your own words, what is this challenge asking you to do?

There it is above your post
and thank you so much for helping

Ok, but how do you know which ‘things’ to switch or make? Where is that information? What are you supposed to switch to?

Understanding exactly what you should do is half of the difficulty of this challenge.

I think the info is coming from the input of the function in the brackets

updateRecords();

and im not really switching but more like creating data in the object

Is that right?

Sure. To add some more detail, you have 4 variables that are important -

  • records - a set of records that you can look up by the id number
  • id - the id number of the record you want to update
  • prop - the property of the record you want to change or delete
  • value - the value you want to set the property to or an empty string to indicate you want to delete the property.

So, the first big question is: How do you get the record with the specified id number?

Maybe do

recordCollection.id.record

Careful. You can only use dot notation with the exact name of a property. We don’t have exact property names. We have variables holding property names, which means we can’t use dot notation here.

Then maybe

recordCollection = record

Where is record defined? I don’t see that in the list of 4 variables we have access to.

Do you remember bracket notation?

Sorry records not record