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

Using this method to add properties, how would you add a property that has a space in the name..?

Since the prior class mentioned that the bracket method needs to be used to reference properties with spaces in the name, how would you add a property to an object literal that has a space in the name?

1 Answer

Dmitry Polyakov
Dmitry Polyakov
4,989 Points

you just use quotation marks for example, you have an object const man = { name: 'John' }; to add a new property you do this: man.car = 'Ford Focus';

Thank you kindly! Figured it was something like that.