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 JavaScript Loops, Arrays and Objects Tracking Data Using Objects The Build an Object Challenge, Part 1 Solution

Saqib Ishfaq
Saqib Ishfaq
13,912 Points

dont understand why has dave used numbers as strings in students array for the points and achievements?

on the 1st object he used numbers as numbers but rest of the objects he put quote marks around numbers .... why? i havent changed them to strings, and it worked fine but wondering as i am proceeding towards the student search challenge... would it cause any issues then?

4 Answers

Steven Parker
Steven Parker
229,744 Points

Good eye! I didn't notice that when I took this course, and it is quite curious. But it won't cause any problem just for printing things out or finding students by name.

But it could indeed be a problem if you were to later write some code that did some math on the values (such as compute an average) or if it did comparisons between the student records.

Yep! Came here to ask the same thing! Second time today he tells you to do something as he does something different in the exercise.

I was also curious about the mixing of strings and values for some of the properties.

copy that! Is it because a JSON-format should be in string but is formed in such as way it can be use as JS ?

Also was wondering about this, in the first pair of numbers he does not use a string, and then uses a string for the rest of them. Kind of confusing, but I see it works either way.