Remove string after "dot" in a number

-1

I have in a variable in javascript the value:

<script>
var valor1 = "123.33";
</script>

I would like to remove .33, leave only 123. Given that this value is variable, it could be 1233.30, 1001.44, anyway ...

    
asked by anonymous 15.01.2018 / 10:19

2 answers

8

You already have something tested that is parseInt() .

console.log(parseInt("123.33"));
    
15.01.2018 / 10:23
1
var str = "123.33";
var res = str.split(".");

alert(res[0]);

res [0] = 123

    
15.01.2018 / 10:23