turn a number into percentage js code example
Example 1: get percentage of number javascript
//Our number.
var number = 120;
//The percent that we want to get.
//i.e. We want to get 50% of 120.
var percentToGet = 50;
//Calculate the percent.
var percent = (percentToGet / 100) * number;
//Alert it out for demonstration purposes.
alert(percentToGet + "% of " + number + " is " + percent);
//The result: 50% of 120 is 60
Example 2: javascript percent to int
parseFloat('42.42%');// => float val = 42.42