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 trialammarkhan
Front End Web Development Techdegree Student 21,661 PointsJavascript 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
ammarkhan
Front End Web Development Techdegree Student 21,661 PointsHow will it help me?
Baptiste Fehrenbach
2,227 PointsTo initialize a variable you have to write 'var myVar = value', you forget the 'var' !
ammarkhan
Front End Web Development Techdegree Student 21,661 PointsNot using it globally. globally variable needs var
Baptiste Fehrenbach
2,227 PointsA globally variable doesn't need var (except if it's global to 'window') but a local variable always need var
Baptiste Fehrenbach
2,227 PointsBaptiste Fehrenbach
2,227 PointsI was testing your code ! And your code is working: when I set amount to 1000 it make 1150 !