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.


Enrica Fedeli-Jaques
Enrica Fedeli-Jaques
6,773 Points

Hi! anyone that could check my code and give me feedback? TIA :)

Hi, my code works, although I had to change a bit the assignment, any chance a more experienced person could look at it and tell me if it's looking OK or 'messy'? thank you :)

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

var numberOne = prompt("Please type a number");

var numberOneConverted = parseFloat(numberOne); console.log(numberOneConverted);

var numberTwo = prompt("Please type another number"); var numberTwoConverted = parseFloat(numberTwo); console.log(numberTwoConverted);

var addition=numberOneConverted+numberTwoConverted; var sub=numberOneConverted-numberTwoConverted; var times=numberOneConverted*numberTwoConverted; var divided=numberOneConverted/numberTwoConverted; var message = 'Math using the numbers ' + numberOneConverted + ' and ' + numberTwoConverted + '<br>' + 'Sum of your two numbers is ' + addition + '<br>' + 'Subtraction of your two numbers is ' + sub + '<br>' + 'Multiplication of your two numbers is ' + times + '<br>' + 'Division of your two numbers is ' + divided+ '<br>';


1 Answer

Ur code is not dynamic. you should create a function for each operation that gets 2 arguments(number1,number2) and to the desired operation on them, this way you can call the functions multiple times without creating new variables.

another thing is the parsing, in each function u can define that this variables should be parsed like so: numberOne = parseFloat(numberOne);

you should use the new es6 const and let keywords, there can be expected problems when u use var. and u should use template literal to format it’s way easier .

all this stuff are thought in the intro to es6 courses but in your current position if i were you i prob would read a few discussion on google about those concepts , it will make you’re life easier

Enrica Fedeli-Jaques
Enrica Fedeli-Jaques
6,773 Points

thanks a lot for your feedback script ninja. I'll go back and look at it again. thank you!