How to remove numbers from a string?

0

Hello, it should be something easy, but I'm breaking the head to solve.

I have a string, String(ValorTotal).replace("." , ""); //tira ponto This string returns me the following value: 23600000000000004 What I need is, remove those 0000000000004 numbers and leave only 2360 .

If anyone knows, help me!

    
asked by anonymous 25.12.2017 / 08:35

1 answer

0

To capture only the first 4 digits, simply use the substr

var valor = String(ValorTotal).replace("." , "");
valor.substr(0, 4); // Captura do primeiro ao quarto dígito.
    
25.12.2017 / 08:51