Basic JavaScript - Use the parseInt Function

Basic JavaScript - Use the parseInt Function
0.0 0

#1

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) {

}

convertToInteger(“56”);


#2

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


#3

Don’t forget to return.

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

convertToInteger(“56”);


#4

Damn it I was forgetting the return part! Ahhhh.