views:

700

answers:

3

e.g

1.2=1 1.5=1 1.9=1

+11  A: 

Using Math.floor(number).

Robert Massa
http://www.w3schools.com/jsref/jsref_floor.asp
number>0?Math.floor(number):Math.ceil(number) to handle the negative case if needed
gnarf
+3  A: 

You can also use

newNumber = parseInt(number);

Nobik
You shuld always stipulate the base parameter with parseint e.g. parseInt(number,10). The if you do not, zero-padded numbers may parse as octal.
James Wiseman
You're right, i have forgot this.In the most cases this conversion will done
Nobik
+1  A: 

for negative numbers you can just use Math.abs(num) and it will knock off the - sign from the start

danwellman