Challenge Accessing Nested Objects doesn't ignore spaces but JS does.
See original GitHub issueChallenge Accessing Nested Objects has an issue.
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) 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 myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};
// Only change code below this line
var gloveBoxContents = myStorage.car.inside[ 'glove box' ]; // Change this line
When you do myStorage.car.inside[ 'glove box' ];
the challenge doesn’t pass the:
Use dot and bracket notation to access myStorage
However, JS ignores the spaces outside of the single quotes. and access a property with:
[ 'name with a space' ]
is valid.
To pass the challenge you’re required to do:
var gloveBoxContents = myStorage.car.inside['glove box'];
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Accessing Nested Objects, freeCodeCamp Basic Javascript
Accessing nested objects in javascript. In this challenge we learn how to access values inside of objects by using bracket or dot notation ......
Read more >Access nested property with spaces in key - javascript
var theKey = "nestedObj['My key has spaces']";. How do I use this string variable to get the value from the object? The obvious...
Read more >freeCodeCamp Challenge Guide: Accessing Nested Objects
Accessing Nested Objects. Hints. Hint 1. Use bracket notation for properties with a space in their name. If we look at our object:...
Read more >Accessing Nested Objects in JavaScript - DEV Community
Let's take this nested object as an example. const name = user.personalInfo.name; const userCity = user. personalInfo.
Read more >Top 10 Most Common Node.js Developer Mistakes - Toptal
However, what if we want to export this function directly, and not as the property of some object? We can overwrite exports to...
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
I think we could update the regex as @dhcodes said to allow a space. cc/ @FreeCodeCamp/issue-moderators
Hi