How to convert percentage to decimal in JavaScript

How to convert percentage to decimal using JavaScript

Posted by Ervin Adams on August 18, 2022

How to convert percentage to decimal in JavaScript

How to convert percentage to decimal using JavaScript

Posted by Ervin Adams on August 18, 2022

Here's how you can convert percentage to decimal:

Step 1. Pass the percentage string in parseFloat() method

Step 2. Divide the result from step 1 by 100

The parseFloat() converts the percentage to float number.

Here is an example below:

 

var percent = "25%";
var result = parseFloat(percent) / 100;
console.log(result); //0.25

 

Any question?
This field is required
Your question have been successfully submitted and will be reviewed before published
Please login to ask a question