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 trialKhashayar Mirbabaie Ghane
Full Stack JavaScript Techdegree Graduate 27,891 PointsMy solution works and i think its a bit easier hope it helps !
alert("Hello and welcome,let's do little math !");
//instantly making strings into numbers
const firstnumber = parseFloat(prompt('Enter your first number please'));
const secondnumber = parseFloat(prompt('Enter your first number please'));
//declaring the calculations
const sumnumbers = firstnumber + secondnumber;
const minusnumbers = firstnumber - secondnumber;
const dividenumbers = firstnumber / secondnumber ;
const multiplenumbers = firstnumber * secondnumber;
//putting tags on the page for printing
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}
`;
1 Answer
Luis Leyva-Madrid
2,937 PointsNot gonna lie, that makes it super clean and organized. I like the way you did it! After I finished the challenge I saw your answer and decided to follow the format you did. Somehow it's easier for me to understand. Thanks!