# Use the parseInt Function (Confused)

Tell us what’s happening:
Well I used "return parseInt(“str”);

And it just gives me
// running tests

convertToInteger(“56”) should return 56

convertToInteger(“77”) should return 77

// tests completed

I do understand the concept of the return but it still doesn’t work somehow. I even read a lot of Forums where they used “str” in the parseInt. Which just confuses me.

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

convertToInteger("56");
``````

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36`.

You’re trying to run parseInt on the actual literal string `"str"`, you’re supposed to be using the variable `str`. Your function doesn’t do anything with the argument you give it - it just runs `parseInt("str")` every time.

Hmm, can you give an example?

Look at the function:

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

The function takes an argument (`str`), but you don’t use it in parseInt

1 Like

Okay, makes more sense now. But I still don’t get how I’m supposed to get it to give me 56 and 77.

Ah, I figured it out I get what I did wrong. I mistakenly put it in a string which it wasn’t supposed to be. And I edited

``````convertToInteger("56");
``````

to 77.

So a function is just a way to define an operation that you want to do:

``````function addTwo(num) {
return num + 2;
}
``````

So you use it like:

``````addTwo(2) // returns 4
``````

Whatever argument you give that function is what `num` is.

So with `convertToInteger(str)`, if you do `convertToInteger('56')`, then `str` is going to be `'56'`

Yeah, I feel a little stupid(sorry for the language).
I didn’t notice it said to not be in a string.
But I fixed it now by removing the string, and changed

``````convertToInteger('77')

``````

It’s dead easy to do, don’t feel stupid. The editor won’t even highlight that there is an error, because it’s perfectly valid code (even though it in no way does what you want, and it will just fail the tests).

The code editor is quite helpful though once you get close to the right thing - if you hover over the functions (convertToInteger and parseInt) it gives hints as to what they want, and when you start typing it will also try to give you hints as to what should go in