Select the first value of a decimal

1

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. 
    
asked by Edy Lasso 26.05.2017 в 01:16
source

2 answers

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.

    
answered by 26.05.2017 в 01:47
-1

You can use the Math.floor , it returns the first number.

    
answered by 26.05.2017 в 01:46