question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Challenge Accessing Nested Objects doesn't ignore spaces but JS does.

See original GitHub issue

Challenge 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:closed
  • Created 7 years ago
  • Reactions:6
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
ghostcommented, Aug 14, 2016

I think we could update the regex as @dhcodes said to allow a space. cc/ @FreeCodeCamp/issue-moderators

0reactions
Timmaaaacommented, May 16, 2017

Hi

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found