Formatting issue within Basic Javascript, Record Collection
See original GitHub issueDescribe your problem and how to reproduce it:
For the challenge Javascript Algorithms and Data Structures -> Basic Javascript -> Record Collection, the collection
variable is not supposed to change, but whenever you format the code (Control + Shift + i) the collection
changes, which will fail the challenge and since it only removes single space character it’s hard to notice.
To reproduce
- Go to the challenge.
- Press Control + Shift + i to format the code.
- Run the tests. The first test fails with You should not change the collection object’s initialization, even though the user didn’t really modify it.
Add a Link to the page with the problem: https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/record-collection
Updating the challenge to remove the space and fixing the RegEx should solve the issue:
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: [ ] // <-- Remove this space
},
5439: {
album: "ABBA Gold"
}
};
And update the test/regex accordingly.
Issue Analytics
- State:
- Created 3 years ago
- Comments:30 (30 by maintainers)
Top Results From Across the Web
Basic JavaScript - Record Collection - JavaScript
Tell us what's happening: Describe your issue in detail here. ... Do we need to set const records to [id][prop][value] at the beginning?...
Read more >Record Collection Tips - Zoho Cares
Zoho has done a VERY great job on making loops and record collection for us EASY! Here's a really basic loop in JAVASCRIPT....
Read more >FreeCodeCamp: I am stuck on "Record Collection"
If prop is "tracks" and value isn't empty (""), push the value onto the end of the album's existing tracks array. If value...
Read more >Basic Javascript: Record Collection [Please Help] - Reddit
Hi guys, first-time poster here. I've been stuck on the Record Collection challenge for two weeks now. I feel like I've hit a...
Read more >Manage contact property formatting issues
In the dropdown menu, select Fix formatting issues. ... The rules you set will automatically accept suggestions for records currently listed ...
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
@skaparate What are your thoughts about:
_recordObject
to the function.collection
variable as is, so campers can use it to debug.collection
object will be used for the tests”@skaparate After watching your video, I now know what the issue is. When I was testing it, I only used the function and not the function and the call to the function (which is part of the seed code). If you comment out the call to the function, it works as expected. However, we do not want a test to fail just because of a user making a call to the function while they are testing things out.
The reason calling the function with
updateRecords(5439, "artist", "ABBA")
causes it to fail, is based on how our test runner works. Each test is completely isolated from each other. However, for each test all the code in the editor (the function plus the call to the function) is executed before each test runs. That means, when the first test runs, the call to the function updatescollection
before the testString is evaluated. So, it will never be “equal” to __recordObject, because “artist”: ABBA" gets added to the property 5439 before the assert.I will need to ponder this overnight. If I can not figure out a way to resolve, then we will have to move forward with a regex approach.