(Use the parseInt Function)

(Use the parseInt Function)
0

#1

Tell us what’s happening:
I don’t have understand what i should do

``````
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`.

#2

In the challenge example, do you understand that the following line converted the string “007” into the number 7 and assigned it to the variable a?

``````var a = parseInt("007");
``````

If so, see if you can use the parseInt function on the argument passed into the function (str) and return the converted number.

#3

Okay That I understand it the first is right now for others I don’t understand what to do

#4

To which others are you referring?

#5

convertToInteger(“56”) should return a number
convertToInteger(“56”) should return 56
convertToInteger(“77”) should return 77
convertToInteger(“JamesBond”) should return NaN

At that I don’t understand the code that I should do?
I try convertTolnteger(“56”)
and of all them same with the code above but it isn’t right

#6

Do you understand what the str parameter represents in the function definition?

Do you understand that parseInt is a function which will attempt to convert any string passed to it into Integer value?

Do you understand how to return a value in a function?

#7

I understand of all this but i don’t understand the last one.

#8

I don’t understand the last sentence

#9

Review the following lesson to understand how to return a value from a function.

https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/return-a-value-from-a-function-with-return/

#10

I read it but again I don’t understand it sorry for tiredness but I don’t understand it

#11

I believe it is easy but now I have many hours which I try to do it and mmy brain has got tired

#12

You do not understand the lesson on how to return a value from a function? If so, which part of that lesson do you not understand?

#13

I don’t understand it all I haven’t got a part of lesson!

#14

You may need to start the Basic JavaScript section again and reset the code for each lesson. You seem to not understand some of the very first basics, so you will struggle very much through any later lessons until you can work through the first lessons without having to ask for help.