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 addition using parseINT

I m on track for JS full stack and was doing something to use parseINT on maths. But my code doesn't work properly, if i want to ass 700+25, it shows 70025. Whereas it should show 725. Why is that?

` if(amount >= 1000){ percent = parseInt((amount/100)) * 15; percentage = amount + parseInt(percent); document.getElementById("total-repay").innerHTML = percentage;


2 Answers

How will it help me?

I was testing your code ! And your code is working: when I set amount to 1000 it make 1150 !

To initialize a variable you have to write 'var myVar = value', you forget the 'var' !

Not using it globally. globally variable needs var

A globally variable doesn't need var (except if it's global to 'window') but a local variable always need var