What is this asking?

Tell us what’s happening:
I really struggle with the wording of some of these problems. I don’t understand what this is asking me to do , I’ve specified below which bits don’t make sense to me.

If prop isn’t "tracks" and value isn’t empty ( "" ), update or set the value for that record album’s property. - To what?

If prop is "tracks" but the album doesn’t have a "tracks" property, create an empty array before adding the new value to the album’s corresponding property - What new value?

If prop is "tracks" and value isn’t empty ( "" ), push the value onto the end of the album’s existing tracks array. - What value am I pushing on to the end of the array? It already has values, what others am I supposed to be adding?

I haven’t added any code yet because I don’t understand the question. Thanks for any help you can give me!

Your code so far


// Setup
var collection = {
2548: {
  album: "Slippery When Wet",
  artist: "Bon Jovi",
  tracks: [
    "Let It Rock",
    "You Give Love a Bad Name"
  ]
},
2468: {
  album: "1999",
  artist: "Prince",
  tracks: [
    "1999",
    "Little Red Corvette"
  ]
},
1245: {
  artist: "Robert Palmer",
  tracks: [ ]
},
5439: {
  album: "ABBA Gold"
}
};

// Only change code below this line
function updateRecords(id, prop, value) {


return collection;
}

updateRecords(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/80.0.3987.149 Safari/537.36.

Challenge: Record Collection

Link to the challenge:

  • To the value, with which function is being called.
  • After creating array for tracks add track that’s passed in value argument
  • Simply the tracks name, that’s being passed in value argument is supposed to be added to the end of the tracks array.

@KittyKora Please avoid copying/pasting the Guide text as an answer. Try to answer the specific questions posted by the OP instead.

Thank you.

I’m sorry, that makes absolutely no sense to me whatsoever. Can you please explain what you mean?

1: If prop isn’t "tracks" and value isn’t empty ( "" ),
return
set the value for that record album’s property. - To what?
To the value.

function updateRecords(id, prop, value) {

2: If prop == "tracks"
but the album doesn’t have a "tracks" property,
create an empty array before adding the new value to the album’s corresponding property
The track thats would be now in the value

 tracks: [
      "Let It Rock",
      "You Give Love a Bad Name"
    ]

3: If
prop is "tracks" and value isn’t empty ( "" )
.push() the value onto the end of the album’s existing tracks array.
We are still busy with tracks here.

@RandellDawson alright as you wish

Under the challenge description there are few examples, which later will be called to test your function, with expected results. Take a look at these they should give some idea how using this function might look like.

Hi, here is your answer:
To the value.
The track thats would be now in the value
We are still busy with tracks here.

I don’t understand what you mean by any of these. Please can you elaborate?

Yes, I’ve seen those. That doesn’t answer my question at all. Perhaps you could elaborate on my original questions?

Rather then answering your questions again.
I am going to ask you a couple.
The value/tracks. Where in the code can you find the word value/tracks?
Don’t look at the text just the code alone.
What is it and what do you think they do?

HINT:
Think about what a value is
It means something has value right?
like say x = 5;
x now has the value of 5 it can be seen as a container storaging something.

Hi - I understand what a value is, I don’t understand what I’m supposed to be updating the value for. Is it literally a case of return the value of this value? That doesn’t make sense.

to the value of the value variable (function parameter)

the value of the value variable that you need to add to the tracks array

the value of value variable that you need to add to the end of the tracks array

for all of these, see the description of the function in the second paragraph:

Write a function which takes an album’s id (like 2548 ), a property prop (like "artist" or "tracks" ), and a value (like "Addicted to Love" ) to modify the data in this collection.

Gonna use example anyway.
updateRecords(5439, "tracks", "Take a Chance on Me")
prop == "tracks" and value is not empty, so function is supposed to update or set tracks prop with the given value - ("Take a Chance on Me").

Additionally:

If record with ID 5439 doesn’t have already tracks attribute, tracks attribute needs to be added with empty array first.

If record with ID 5439 already have tracks attribute, the given value ("Take a Chance on Me", needs to be added at the end of the tracks array.

Thanks for all your advice. What I’m finding today is that a lot of the JS challenges have a decent explanation of the concept but then seem to throw a curve ball with the challenge. Sometimes like this one the explanation of what the challenge is asking doesn’t make sense to a new starter and other times it seems the concept is explained on the next challenge instead.

I’ve abandoned this one for now to stop me throwing my laptop across the room but your explanation of value did begin to make sense for me so thank you and I shall come back to this when I’ve done a bit more JS.

I think a lot of the problem is that the challenge is illogical - why update the value when it is already correct?

there is no concept of correctness in this challenge, nor in the function

the function should be able to update the object based on inputs (so if value parameter is an empty string, delete, and if it is not an empty string then add/change property values to the indicated object)

1 Like

I don’t think that’s much of an answer. Can you explain what you mean? I understand the end goal of the function but it’s illogical from a learning perspective.

why do you think it is illogical?

the goal of this challenge is to create a function with a specific behaviour described in the instructions.