"After updateRecords(2468, "tracks", "Free"), tracks should have "1999" as the first element." still failing even with output correct.
See original GitHub issueChallenge Record Collection has an issue.
User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36
.
Please describe how to reproduce this issue, and include links to screenshots if possible.
My code:
// 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"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));
// Only change code below this line
function updateRecords(id, prop, value) {
if (prop !== "tracks" && value !== "") {
collection[id][prop] = value;
} else if (prop == "tracks" && value !== "") {
if (!collection.hasOwnProperty("tracks")) { // moved from outside loop
collection[id]["tracks"] = [];
collection[id][prop].push(value);
} else {
collection[id][prop].push(value);
}
} else { // removed (value === "")
delete collection[id][prop];
}
return collection;
}
// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
"After updateRecords(2468, "tracks", "Free"), tracks ... - GitHub
"After updateRecords(2468, "tracks", "Free"), tracks should have "1999" as the first element." still failing even with output correct. #10132.
Read more >I don't why it is bringing this error - The freeCodeCamp Forum
This is the errror: After updateRecords(recordCollection, 2468, “tracks”, “Free”), tracks should have the string 1999 as the first element.
Read more >Question about JavaScript Algorithms and Data Structures
While doing the recordCollection problem, I thought I solved it, but the site is saying some of the tests are failing even though...
Read more >Uncaught (in promise) DOMException: play() failed because ...
According to the new browser policy, the user must interact with DOM first before playing the Audio element. If ...
Read more >Free Code Camp - Basic Javascript Flashcards | Quizlet
Sometimes you will need to build a string, Mad Libs style. By using the concatenation operator (+), you can insert one or more...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
else if (prop == “tracks” && value !== “”) { // you said in this line my prop= “tracks” then let go inside the if if (!collection.hasOwnProperty(“tracks”)) { // then you said if “tracks” does not inside collection but with wrong syntax you should write if(!collection[id].hasOwnProperty(“tracks”)) collection[id][“tracks”] = []; collection[id][prop].push(value);
but totally you think wrong somewhere because if your value = null, you have to delete the item inside the object, so your first statement should be if(value = “”) {delete collection[id][prop];
@Xelepam ! is the logical NOT operator. In this context, it would be the same as saying if the ID of the collection does not have the property “tracks” in human speak.