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 The Solution

My solution is a bit different and I think easier !

alert("Hello and welcome,let's do little math !");

const firstnumber = parseFloat(prompt('Enter your first number please'));
const secondnumber = parseFloat(prompt('Enter your first number please'));

const sumnumbers = firstnumber + secondnumber;
const minusnumbers = firstnumber - secondnumber;
const dividenumbers = firstnumber / secondnumber ;
const multiplenumbers = firstnumber * secondnumber;

const main = document.querySelector('main');
main.innerHTML = `
<h1>your numbers are ${firstnumber} and ${secondnumber}, so these are the calculations:</h1>
<br>
<p> the sum of ${firstnumber} + ${secondnumber} = ${sumnumbers}
<p> the minus of ${firstnumber} - ${secondnumber} = ${minusnumbers}
<p> the divide of ${firstnumber} / ${secondnumber} = ${dividenumbers}
<p> the multiple of ${firstnumber} * ${secondnumber} = ${multiplenumbers}
`;

3 Answers

alert("Let's do some Math!")

const inputOne = prompt("What is your first number?"); const numOne = parseFloat(inputOne);

const inputTwo = prompt("What is your second number?"); const numTwo = parseFloat(inputTwo);

const message = (<h1>Math with the numbers ${numOne} and ${numTwo}</h1> ${numOne} + ${numTwo} = ${numOne + numTwo} <br> <br> ${numOne} * ${numTwo} = ${numOne * numTwo} <br> <br> ${numOne} / ${numTwo} = ${numOne / numTwo} <br> <br> ${numOne} - ${numTwo} = ${numOne - numTwo});

document.write(message);

i dont know it didnt get copy well or what but im gettin 18 errors on your code :D

clean.. I like it. well done.

I did something similar by making use of ${} inside of ``.

cheers , glad it was helpful .