freeCodeCamp/guide/english/certifications/javascript-algorithms-and-d.../basic-javascript/use-the-parseint-function/index.md

469 B

title
Use the parseInt Function

Use the parseInt Function

The parseInt() function will take any string parameter representing a number and return its integer value.

Hint 1

parseInt() should be used inside your function and return whatever str is, assuming that str is a string representing some number.

Solution

function convertToInteger(str) {
    return parseInt(str); 
}

convertToInteger("56");