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

Can someone check out my Code? Thanks

https://w.trhou.se/vix979aymm

i skimmed through dave's code in the solution after i did it "my" way lol

thoughts? thanks

1 Answer

Gabriel Plackey
Gabriel Plackey
11,064 Points

Could maybe simplify it with changing

var message = firstNum + " + " + secondNum + " = "  
var totalofNum = firstNum + secondNum + "<br>"
document.write(message);
document.write(totalofNum);

To something like

var totalofNum = firstNum + secondNum
var message = firstNum + " + " + secondNum + " = "  + totalofNum + "<br>"
document.write(message);

For each of the like blocks of coded, gets rid of a line of code that is not really needed with the double document write

Same concept with

var secondNumInput = prompt("Please enter another number");
var secondNum = parseInt(secondNumInput);

To

var secondNum = parseInt(prompt("Please enter another number"))
Gabriel Plackey
Gabriel Plackey
11,064 Points

This is just being nitpicky and showing how you can write less lines of code and be more efficient. Otherwise it looks good and gets the job done.