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 trialMary Kong
1,146 PointsSelf 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
Biruktawit Galoro
Front End Web Development Techdegree Graduate 12,661 Pointsmessage = <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
Biruktawit Galoro
Front End Web Development Techdegree Graduate 12,661 Pointscan you share(post) your code so i will be able to see what's wrong?
terd47
4,436 PointsPlease share your code let's see what you got so we can better assist you.
Mary Kong
1,146 PointsThanks @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>
;
Biruktawit Galoro
Front End Web Development Techdegree Graduate 12,661 Pointsthe first one looks good but what is the the word ' massage'. is it a variable?
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
1,146 PointsI 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);
Mary Kong
1,146 PointsMary Kong
1,146 PointsI am so embarrassed. Thanks so much. For the life of me, I couldn't figure it out. Thanks!
It is so apparent now!