Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript AJAX Basics Programming AJAX Programming AJAX Challenge

Why are the values associated with the keys in the JSON files not wrapped in double quotes?

I remember from another video that key/value pairs must be wrapped in double quotes in order for the JSON to be valid. In this challenge, the conditional isn't matching string values, it's matching whether rooms.available or employees.inoffice === true or false. Why is this?

2 Answers

In JSON files like employees.json ```{ "name": "Aimee", "inoffice": false }

they key always has quotes around it, but the values only has quotes if it's a string. The key inoffice holds a value of JavaScript type boolean, which is false, which is not a JavaScript string. 

But if it was 

```{
   "name": "Aimee",
   "inoffice": "false"
  }

then the key inoffice would have a value of JavaScript string which contains "false".

So if you compare with a boolean type:

inoffice === false, is using three === for a strict comparison, so inoffice must be of type boolean.

Tony Idehen
Tony Idehen
8,060 Points

The values number and boolean data types should Not be wrapped in double quotes. Keys must be in double quotes. If the value is a string data type it should be wrapped in double quote.