I am not sure how to begin. Please help

Tell us what’s happening:
Describe your issue in detail here.
I’m having a hard time with this challenge. I don’t know how to begin and construct the solution. Honestly, I think I am having difficulty understanding the question. I understood the topics before this fine, I guess I’m not sure how to put it all together and to use.

  **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) {
return records;

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

  **Your browser information:**

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

Challenge: Record Collection

Link to the challenge:

I would just create the logic for each bullet point one at a time. The first bullet point:

Your function must always return the entire record collection object.

has already been done for you as the function ends with return records;

The first bullet point is:

“If prop isn’t tracks and value isn’t an empty string, update or set that album’s prop to value .”

This sounds like an if statement to me. Do you think you could create the logic for this if statement and then do what it says if the statement is true?

Would you be able to break down that bullet point? Specifically the part, " If prop isn’t tracks and value isn’t an empty string". I know that’s the “if” statement that you mentioned in your answer but I cant understand what it’s asking.

What do you think prop is referring to here? The instructions sort of give it away [a prop (like artist or tracks)]. Look at the setup object above the function. Do you see what these are referring to?

Is that statement essentially saying if the album id does not have a track property or if the value is an empty string then to update the value of the empty string string to the album ID, in this case the prop?

I don’t see that in the bullet point, personally.

That sounds like the opposite of the bullet point’s instructions.

I’m not sure how one would update the value of an empty string?

No, this bullet point has nothing to do with whether an object has a certain property. It only cares about the values of the arguments passed into the function.

The bullet point begins (comparison A):

"If prop isn’t tracks"

The word “isn’t” can be thought of as “is not equal to”. So you are comparing two values and you want to use a comparison operator that is equivalent to “is not equal to”. The value on the left is the variable prop which is passed into the function. Do you understand what the prop variable represents? You’ll need to in order to know how to compare it to tracks.

The bullet point continues (comparison B):

“and value isn’t an empty string”

Let’s forget about and for a second. You have another “isn’t” here so we already know that you’re doing a comparison to see if something is not equal to something else. The value on the left is passed into the function and I’m hoping you know how to represent an empty string in JS.

Back to the and. This means you want both of these comparisons to be true. This is referred to as a logical AND. Do you know the operator for a logical AND?

So you have:

if ((comparison A) AND (comparison B)) {
     update or set that albums prop to value

Replace with the equivalent JS code.

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