Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert percentage value to int

Tags:

javascript

How is it possible to convert in JavaScript for an example 7.35% to int value, so that I get 7.35 as result?

Note: method parseInt() does not work!

like image 406
mehmedju Avatar asked Aug 06 '15 13:08

mehmedju


People also ask

How do you convert 20% to a number?

So it is clear that we can convert percent to whole number by dividing it 100 but it is not necessary that it will always give result in whole number. Some Examples of percentage, 20% of 300 is equal to (20/100) × 300 = 60.

Is a percentage An integer?

Therefore, these numbers can never be integers: fractions. decimals. percents.


1 Answers

Use parseFloat

parseFloat('42.42%');// => float val = 42.42
like image 66
ImmortalPC Avatar answered Sep 28 '22 06:09

ImmortalPC