Basic JavaScript - Use the parseInt Function

Hey anybody can help out?

convertToInteger should use the parseInt() function
convertToInteger(“56”) should return a number
convertToInteger(“56”) should return 56
convertToInteger(“77”) should return 77
convertToInteger(“JamesBond”) should return NaN

my code:
function convertToInteger(str) {



Inside convertToInteger you are passed a string parameter str. parseInt takes a string and returns an integer. So for example: parseInt(“10”) returns the number 10

Don’t forget to return.

function convertToInteger(str) {
return parseInt(str)



Damn it I was forgetting the return part! Ahhhh.

1 Like