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 Introducing the Practice

Mary Kong
Mary Kong
1,146 Points

Self closing tags don't work. (i.e. <h1> and </h1>).

I am trying to add format to my code, and it looks like none of the closing tags work, so I can't style my project. All of the sentences run together. I am not quite sure what is wrong.

message `<h1> Let's create math with the numbers ${prompt1} and ${prompt2}.</h1>`; 

I also tried it this way

message <h1> `Let's create math with the numbers ${prompt1} and ${prompt2}.`</h1>; 

6 Answers

message = <h1> Let's create math with the numbers ${prompt1} and ${prompt2}.</h1>;

if you add '=' after 'massage' it should work. for the first code you provided above it seems you forget to add = after message

Mary Kong
Mary Kong
1,146 Points

I am so embarrassed. Thanks so much. For the life of me, I couldn't figure it out. Thanks!

It is so apparent now!

can you share(post) your code so i will be able to see what's wrong?

Please share your code let's see what you got so we can better assist you.

Mary Kong
Mary Kong
1,146 Points

Thanks @birkuktawit Galoro and @terd47 for reaching out. I ended up utilizing a different way (may be the correct way) to add headers. I originally tried it the following way:

message <h1> Let's create math with the numbers ${prompt1} and ${prompt2}.</h1>;

the first one looks good but what is the the word ' massage'. is it a variable?

Mary Kong
Mary Kong
1,146 Points

"message" is a variable that I defined earlier at the top of the screen.

For some reason, when I ran the top message, it didn't work. I ended up using the following, which worked:

message = "<h1>Let's create math with the numbers " + prompt1 + " and " + prompt2 + "</h1>";
Mary Kong
Mary Kong
1,146 Points

I appreciate your help with this, it's been a process learning the right way to write the code, what works and what doesn't and alternate ways to approach things. I am not sure if this helps, but this is the following code that I ran that works:

var intro
var prompt1
var prompt2
var message

intro = alert ("Let's work on creating some mathematical equations today!"); 

prompt1= prompt ("Pick a number, any number.");

prompt1 = parseFloat(prompt1);

prompt2= prompt ("Pick another number, your favorite number, or even the same number."); 
prompt2= parseFloat (prompt2); 

message = "<h1>Let's create math with the numbers " + prompt1 + " and " + prompt2 + "</h1>";

message += prompt1 + " + " + prompt2 + " = " + (prompt1 + prompt2); 
message += "<br>";
message += prompt1 + " - " + prompt2 + " = " + (prompt1 - prompt2); 
message += "<br>";
message += prompt1 + " x " + prompt2 + " = " + (prompt1 * prompt2);
message += "<br>";
message += prompt1 + " / " + prompt2 + " = " + (prompt1 / prompt2);

document.write (message);

This is the code with the top of the line written in instead; it breaks:

var intro
var prompt1
var prompt2
var message

intro = alert ("Let's work on creating some mathematical equations today!"); 

prompt1= prompt ("Pick a number, any number.");

prompt1 = parseFloat(prompt1);

prompt2= prompt ("Pick another number, your favorite number, or even the same number."); 
prompt2= parseFloat (prompt2); 

message `<h1> Let's create math with the numbers ${prompt1} and ${prompt2}.</h1>`;

message += prompt1 + " + " + prompt2 + " = " + (prompt1 + prompt2); 
message += "<br>";
message += prompt1 + " - " + prompt2 + " = " + (prompt1 - prompt2); 
message += "<br>";
message += prompt1 + " x " + prompt2 + " = " + (prompt1 * prompt2);
message += "<br>";
message += prompt1 + " / " + prompt2 + " = " + (prompt1 / prompt2);

document.write (message);