Answers for "how to make a string into number js"

189

how to convert string to int js

let string = "1";
let num = parseInt(string);
//num will equal 1 as a int
Posted by: Guest on February-24-2020
0

Converting a String into a Number in Javascript

// Converting a String into a Number in Javascript
// Longhand:
const num1 = parseInt("100");
const num2 =  parseFloat("100.01");
console.log(num1);
console.log(num2);

// Shorthand:
const num3 = +"100"; // converts to int data type
const num4 =  +"100.01"; // converts to float data type
console.log(num3);
console.log(num4);
Posted by: Guest on January-20-2022
0

javascript how to convert string to number

Number.parseInt("24", 10);
Posted by: Guest on August-17-2021

Code answers related to "how to make a string into number js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language