FAQ: Advanced JSX - Variables in JSX

This community-built FAQ covers the “Variables in JSX” exercise from the lesson “Advanced JSX”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Web Development

Learn ReactJS: Part I

FAQs on the exercise Variables in JSX

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

just for the test. added new div in the index.html
<div id="digit"></div>

const digit = 100;
ReactDOM.render(
  <h1>{digit}</h1>,
  document.getElementById('digit')
);

was trying to render this snippet, no output so far :man_shrugging:

But did you have an element in your HTML with and id of “digit”?

Hello

const greeting = <p>Hello, {name}!</p>;

What are the “!” for in that line of code?

Kiss kiss

By this time you have probably figured this out yourself, but those who stumble upon similar problem:

did you import the React and ReactDOM libraries too?

import React from ‘react’;
import ReactDOM from ‘react-dom’;

Hello, @josephgabriel7806611 !

In this particular code “!” is just a part of the text string, a regular “!”.

Like:

Hello, Ben!
Hello, Janet!

1 Like