# Use the parseInt Function2

Tell us what’s happening:
I don’t know what to do please tell me?

``````
function convertToInteger(str) {

}

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

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

Hello!

You have to use the ‘parseInt()’ function to convert the string to an integer.

Try declaring a variable in your function and then use the ‘parseInt()’ function to set its value.

Good luck!

1 Like

Hi !

You should parse the `str` parameter and `return` it inside the given function `convertToInteger`.

Hope this helps !

function convertToInteger(str) {
var a = parseInt(“007”);
}

convertToInteger(“56”);

I do that then what I should do?
I have got right the first but others it is wrong.

Good start, however right now you are putting an already defined string (“007”) into the function instead of a generic one. This means that every time you run your function var a would be equal to 7 no matter which number is placed in the function.

You are also currently not returning anything. Try adding a return statement that will return the result of your function.

1 Like

How can add a return statement?

What code i mean i should need

You have to `parseInt()` the parameter given in `convertToInteger()`, in this case `str` and return the variable you declared, in this case `a`.

Can you explain me more easy because I am and 14 years old and sometimes I don’t understand it.

convertToInteger() = function
str = parameter of convertToInteger function. Note that you can name it anything you want. Like : myString.
convertToInteger(“56”); = when you call the function, the value inside parentheses (in this case “56”) replace the parameter `str`.

So, inside the curly braces `{ }` you should `parseInt()` the parameter and then return the variable `a`.

Omg sorry but It is so hard end I can’t do it!
And you can’t help me more I understand all of this but I have many hours tried everythiing but nothing is right.

No problem! Maybe my explanation is bad.

Try to replace “007” with `str` and then `return` the variable `a` like this: `return a`;

OMG OMG this is right and your explaination isn’t bad thank you so much you help me and sorry if i tired of you thank you again

You’are welcome. I will never get tired of helping. We are a community and help others should be our routine. Hope you will help someone else.

Thank you