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 trialTural Rzazade
3,750 PointsMy solution to the challenge
at first, I was calculating the results of two inputs by using 4 different variables (because of 4 different calculations). then I realized from one of the students' codes that I could do it within the same template literals.
By the way, having these video materials from 2-3 years ago and also hearing the let, const, and var topics such as var is not preferred that much anymore makes me confused a little
// 1. Attach this file -- math.js -- to the index.html file using a <script> tag
// 2. Add an alert to announce the program with a message like "Let's do some math!"
alert("Let's do some math!");
// 3. Create a variable and use the prompt() method to collect a number from a visitor
const inputRawFirst = prompt("Provide a value");
const inputRawSecond = prompt("Provide another value");
// 4. Convert that value from a string to a floating point number
const inputFirst = parseFloat(inputRawFirst);
const inputSecond = parseFloat(inputRawSecond);
const messageFirst = `<h1>Math with the numbers ${inputFirst} and ${inputRawSecond}<br></h1>
${inputFirst} + ${inputSecond} = ${inputFirst + inputSecond} <br>
${inputFirst} - ${inputSecond} = ${inputFirst - inputSecond} <br>
${inputFirst} * ${inputSecond} = ${inputFirst * inputSecond} <br>
${inputFirst} / ${inputSecond} = ${inputFirst / inputSecond} <br>
`;
document.write(messageFirst);