# [Code Example] Convert string into float in javascript & ReactJs

Use `parseFloat()` function to covert `string` into `float` in javascript & ReactJs. The digit before decimal must start with a digit otherwise it will return NaN. Check the code example –

``````function circumference(r) {
return parseFloat(r) * 2.0 * Math.PI;
}

console.log(circumference(4.567));
// expected output: 28.695307297889173

console.log(circumference('4.567abcdefgh'));
// expected output: 28.695307297889173

console.log(circumference('4.ere567abcdefgh'));
// expected output: 25.132741228718345

console.log(circumference('4sdf.ere567abcdefgh'));
// expected output: 25.132741228718345

console.log(circumference('ert4.ere567abcdefgh'));
// expected output: NaN

console.log(circumference('abcdefgh'));
// expected output: NaN
``````

Source: MSDN

### Sign Up for Our Newsletters

Get only the best articles delivered to your mail

## [Code Example] String to lowercase using bash script

In this article I will provide you the bash script code to convert your strings to all lowercase. We require this functionality a lot like when storing usernames, emails, url…

## [Code Example] Convert decimal to binary in javascript & reactjs

To convert a decimal number to a binary number in javascript & reactjs, you can follow these steps – Take a empty string value to hold output. Run a loop…

## [Code Example] x = x * y / z is not equal to x *= y / z for integers

Table of Contents Hide ReasonCode ExampleLive DemoRelated Posts: In this article we will understand why x=x*y/z is not equal to x*=y/z if variables are integers using java code example. Reason…

## [Code Example] Clear Ubuntu terminal or WSL without clearing history

In this article we will provide your code for clearing Ubuntu terminal or WSL windows command line without clearing history. Use clear command with -x attribute. Note: Remember to use…

## [Code Example] Composer dependencies require PHP version

Php throws error composer dependencies require php version > abc when you have lower php version installed in your system. Solution 1. Run php -v to get the php version…

## [Code Example] fzf vim integration

In this article we will give you code for fzf vim integration. You can enable fzf in your vim by adding the fzf directory to &runtimepath in your Vim configuration…