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

I've solved it in another way, is it correct?

alert ("Let's do some maths!");
const numberOne = prompt ('Please, introduce a number');

const numberTwo = prompt ("Please, introduce one more number"); 

const message = `<h1>Math  with the numbers ${numberOne} and ${numberTwo}</h1>
${numberOne} + ${numberTwo} = ${parseFloat(numberOne) + parseFloat(numberTwo)} <br>
${numberOne} * ${numberTwo} = ${parseFloat(numberOne) * parseFloat(numberTwo)} <br>
${numberOne} - ${numberTwo} = ${parseFloat(numberOne) - parseFloat(numberTwo)} <br>
${numberOne} / ${numberTwo} = ${parseFloat(numberOne) / parseFloat(numberTwo)} <br>
`; 

document.write (message);

PS: hope the markdown worked... It's my first time trying to use it.

It worked!!!

2 Answers

Steven Parker
Steven Parker
231,141 Points

You didn't provide a link to the "other way", but I'd guess it may have used concatenation instead of a template string?

If so, this would be functionally equivalent and equally valid. Good job. :+1:

Sorry Steve, can't you see my piece of code above? That was my code, using template strings!!

Steven Parker
Steven Parker
231,141 Points

My original answer was about your code as shown, I just wasn't sure what you were comparing to!
For future questions, consider providing a link to the course page you are referencing.

Steven Parker
Steven Parker
231,141 Points

jara hernández Quijada — Glad I could help. You can mark the question solved by choosing a "best answer".
And happy coding!

Oh, I understand! I was comparing mine to Gill's.