Good morning,
There is some way to select the first value of a decimal, try with toFixed()
but the problem is that I round it up.
For example:
4.560 // necesito el 4 pero con toFixed() me devolverá 5.
Good morning,
There is some way to select the first value of a decimal, try with toFixed()
but the problem is that I round it up.
For example:
4.560 // necesito el 4 pero con toFixed() me devolverá 5.
<!DOCTYPE html>
<html>
<body>
<button onclick="myfuncion()">Presiona</button>
<p id="Ejemplo"></p>
<script>
function myfuncion(){
document.getElementById("Ejemplo").innerHTML = Math.floor(4.560);
}
</script>
</body>
</html>
You need to use the Math.Floor function:
Check this example and it will give you the result.
You can use the Math.floor
, it returns the first number.