Remove string after "dot" on a number

Asked

Viewed 312 times

-1

I have in a variable in javascript the value:

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

I would like to remove the . 33, leave only the 123. Taking into account that this value is variable, it can be 1233.30, 1001.44, finally...

2 answers

8


1

var str = "123.33";
var res = str.split(".");

alert(res[0]);

res[0] = 123

Browser other questions tagged

You are not signed in. Login or sign up in order to post.