## Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

### Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today. # my solution to exercises

// 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('lets do some math'); // 3. Create a variable and use the prompt() method to collect a number from a visitor

var firstNum =prompt ('enter first num'); // 4. Convert that value from a string to a floating point number

firstNum =parseFloat(firstNum); // 5. Repeat steps 3 and 4 to create a second variable and collect a second number

var secondNum =prompt ('enter second num');

secondNum =parseFloat(secondNum); // 6. Create a new variable -- message -- which you'll use to build // a complete message to print to the document // Start by creating a string that includes <h1> tags as well // and the two input numbers. The string should look something like this: // "<h1>Math with the numbers 3 and 4</h1>" where the two numbers are // the values input from the user. Use string concatenation to create this // and make sure you actually perform the math on the values by // using the + symbol to add their values together

var message =`<h1> Math with numbers \${firstNum} and \${secondNum} <h1>`; document.write(message);

// 7. Add another string to the message variable. // The string should look something like this after concatenation: // "3 + 4 = 7"

var calculate =`\${firstNum} + \${secondNum} = \${firstNum + secondNum} <br>`; document.write(calculate);

var subtract =`\${firstNum} - \${secondNum} = \${firstNum - secondNum} <br>`; document.write(subtract);

var multiply =`\${firstNum} * \${secondNum} = \${firstNum * secondNum} <br>`; document.write(multiply);

var divide =`\${firstNum} / \${secondNum} = \${firstNum / secondNum} <br>`; document.write(divide);

// 8. Add a linebreak tag -- <br> -- to the message variable

// 9. Continue to add to the message variable to include strings // demonstrating multiplication, division and subtraction // For example: // "3 * 4 = 12" // "3 / 4 = 0.75" // "3 - 4 = -1"

// 10. Use the document.write() method to print the message variable // to the web page. Open the finished.png file in this workspace // to see what the completed output should look like