Can't solve this challenge

Tell us what’s happening:

Getting stuck the code bellow is what i have so far

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: [
    "Little Red Corvette"
1245: {
  artist: "Robert Palmer",
  tracks: [ ]
5439: {
  album: "ABBA Gold"

// Only change code below this line
function updateRecords(id, prop, value) {
if (prop in tracks && album === no tracks )
return [];
else if (prop in tracks && value = "")
return push(value.pop(trakcs))
else if (value === "")
return  delete prop from album
return collection;

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Safari/605.1.15.

Challenge: Record Collection

Link to the challenge:

you have a whole heap of wrong syntax

you need to be really careful in what you are writing
try again, line by line. What do you want to do? what method or operator or keyword will do that? how do you write that? find it (research!) and fix it

(I will be back in January)


(Edit I picked up the first couple of things I saw, but almost everything here is wrong, as @ilenia says)

in means what you might expect, for (key in object) iterates through an object. if (key in object) checks if there is a key in that object. tracks would be the prop (if it was “tracks”!!! Keys are strings!!! Where are you getting tracks from). And tracks would be an array as well, it makes no sense

no isn’t a JS keyword


Where are you getting the variable tracks from

1 Like

Yeah i know the syntax is wrong but, i wanted to make sure i understand what they asked was the right thing. like im even getting confused with the first line of task:

they want us to check if prop is in tracks
but if the album doesn’'t have tracks prop
they want us to create an empty array
before adding the new value to the corresponding properpty
that seems to be asking something and denying it
do they want us to check prop in tracks or don’t they?

Well happy holliday’s to you (merry christmass and a happy new year) :3 since I am unable to wish you them on the right day.will leave u a card thou

prop is not in tracks, but "tracks" is a possible value of prop, and as the tracks property is an array it needs special handling: you need to add the value at the end of the array, but if the array doesn’t exist you can’t, so if the array doesn’t exist you need to create first the array

1 Like

You’re right. Was able to solve it to keep tracks into a string form. and some other things
would post the code but, i don/'t want to spoil the answer :3 for others