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 Introducing the Practice

just sharing my code

Finished the math practice, and this is my code. (I wish I knew how to keep the color code from the workspace, but still don't know how to.) If you're reading this and have some helpful feedback, please let me know. Thanks!

alert("Let's do some math!");

var input1 = prompt("Please type a number.");
var firstNumber = parseFloat(input1);

var input2 = prompt("Please type another number.");
var secondNumber = parseFloat(input2);

var add = firstNumber + secondNumber;
var multiply = firstNumber * secondNumber;
var divide = firstNumber / secondNumber;
var subtract = firstNumber - secondNumber;
var message = ("<h1>" + "Math with the numbers " + firstNumber + " and " + secondNumber + "</h1>"
               + firstNumber + " + " + secondNumber + " = " + add + "<br>"
               + firstNumber + " * " + secondNumber + " = " + multiply + "<br>"
               + firstNumber + " / " + secondNumber + " = " + divide + "<br>"
               + firstNumber + " - " + secondNumber + " = " + subtract + "<br>"                  
              );

document.write(message);

1 Answer

Steven Parker
Steven Parker
231,248 Points

After the 3 backticks (accents) that start the Markdown code area, put the language name to get syntax coloring.

So in this case :point_right:```javascript

And good job on the code, very nice formatting! :+1: