**Tell us what’s happening:**only getting syntax errors when writing out code i try meny examples to but same result fustrated
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) {
if (prop !== 'tracks' && value !== ""){records[id][prop] = value;}else if(prop ==="tracks" && records[id]hasOwnProperty("tracks"))records[id][prop] =[value];}else if (prop === "tracks" && value !== "") {records[id][prop].push(value);
}else if(value ===""){delete records[id][prop];
}
return records;
}
updateRecords(recordCollection, 5439, 'artist', 'ABBA');
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36.
I do see syntax errors on this version of your code. Correct formatting helps show the problem
// Only change code below this line
function updateRecords(records, id, prop, value) {
if (prop !== 'tracks' && value !== ""){
records[id][prop] = value;
// ---------- LOOK HERE ----------
} else if (prop === "tracks" && records[id]hasOwnProperty("tracks")) // LOOK VERY CAREFULLY RIGHT HERE BECAUSE YOU ARE MISSING SOMETHING (TWO THINGS IN FACT)
// ---------- LOOK HERE ----------
records[id][prop] = [value];
} else if (prop === "tracks" && value !== "") {
records[id][prop].push(value);
} else if(value === "") {
delete records[id][prop];
}
return records;
}
updateRecords(recordCollection, 5439, 'artist', 'ABBA');
} else if (prop === "tracks" && records[id]hasOwnProperty("tracks")) // LOOK VERY CAREFULLY RIGHT HERE BECAUSE YOU ARE MISSING SOMETHING (TWO THINGS IN FACT)
I don’t see anywhere that an array is being created in this one line. That can’t possibly be what that one single line does.
There are two syntax bugs in this line. One of them comes from your second condition, which is why I am trying to get you to look at it and actually describe what it does. The second comes from basic if statement syntax.
I get the impression that you are trying to duplicate the solution you are looking at rather than understanding and creating a solution on your own. This sort of approach makes it very easy to write bugs and very hard to find and understand those bugs. I’m trying to get you to try to actually read and understand the code so that you can see where the problems are.
(There is also a logical bug, but its hard to find logical bugs when the code cannot run due to syntax bugs.)