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 React Basics (2018) Introducing Props Iterating and Rendering with map()

How about using " and ' with HTML string?

I'm a bit confused that we don't need to use quote operators inside of {} since it supposes to be JavaScript. Please take a look at my first version of the element App:

const App = (props) => { return( <div className="scoreboard"> <Header title="Scoreboard" totalPlayers={1} /> {/* Players list */} { props.initialPlayers.map(player=> <Player name={player.name} score={player.score} /> )} </div> ); }

Of course, the output is wrong. But I'm still a bit confused about why we don't need to wrap HTML code inside of { } into the quote operators. I hope my question does make sense.

1 Answer

{/* Players list */} is a comment (because of /* */)

<Player name={player.name} score={player.score} these are variables, not strings.

You dynamically assign the value, based on the value of the properties 'name' and 'score' of the player object.

You don't want a string, you want a dynamic value. Hence no quotes. If you'd want a static value you would use quotes (but then why would you need to use react if you want to serve a static page?)