+ 3

How can i get the answer 1 when i divide 1200 to 1000?

Im using the var keyword and still return 1.2, also i used int but i got an error? should i convert it to int? please help.

5th May 2017, 2:13 PM
Jasper Diongco
Jasper Diongco - avatar
5 Réponses
+ 1
use Math.floor
5th May 2017, 2:39 PM
Calviղ
Calviղ - avatar
+ 2
Hi @Masshan You are right, if you talk about C++, unfortunately not in Javascript.
5th May 2017, 2:42 PM
Calviղ
Calviղ - avatar
+ 2
@Calvin thankyou bro. it works!
5th May 2017, 2:46 PM
Jasper Diongco
Jasper Diongco - avatar
+ 1
as how I know 1.2 should be float type variable and as int type variables are not supposed to return numbers with a decimal places you get 1 as the answer. (I'm a newbie)
5th May 2017, 2:32 PM
Mashan Shaluka1
Mashan Shaluka1 - avatar
0
@calvin thanks bro 😊
11th May 2017, 11:33 AM
Mashan Shaluka1
Mashan Shaluka1 - avatar