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


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!