Converting a string to an integer in Javascript

Simple example of converting a string to an integer in Javascript.

Javascript example of converting a string to an int

To convert a string to an int, use parseInt():

const converted = parseInt("10");
console.log(converted);
// output: 10

Noteworthy details

  1. If no integer is found, NaN will be returned.

For other javascript examples: https://www.mikesallese.me/tags/javascript

Still need help?

Didn't find what you need? I'm happy to help folks out.

Feel free to email me at