+ 3
JavaScript parseInt
function convertToInteger(str) { parseInt(str); return parseInt; } convertToInteger("56"); I need to parse any number that enters the function. Please where i'm I wrong?
4 ответов
+ 6
it should be...
function convertToInt(n)
{
return parseInt(n);
}
+ 2
parseInt is a funcion, a function returns a value, and if u want tô return this value, you should to assign this function call to a var, for example: var prs = parseInt("3");
return prs;
In your function, you returned parseInt func, not this return for "56" :p, I'm BR but.. I hope that u be able to understand ;w; srry
+ 1
hello there.
In your exemple you did return the parseInt function. You need return just value instead. Note:
var str = '56';
var decimalNum = parseInt(str, 10);
The ten number force decimal number.
+ 1
Thank you friends 👊