Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок0
What is wrong with this javascript code
var myFunction = function (str, n) { var string = "" ; for(x=0;x<str.length;x++) { string = string + str[x].repeat(n) } return string; } console.log(myFunction("hello again",5 ) )
15 ответов
+ 3
var myFunction = function (str, n) {
var string = "" ;
for(x=0;x< n; x++) {
string = str.repeat(n)
}
return string;
}
console.log(myFunction("hello again ",5 ) )
+ 1
it works fine, I tested it before posting it.
here is even a simpler version.
var myFunction = function (str, n) {
return str.repeat(n)
}
console.log(myFunction("hello again ",5 ) )
+ 1
SoloLearn playground. add it to a web project and paste the code in the Js section and run it.
+ 1
that's weird, it works fine. where did you test it and how exactly?
+ 1
post it to your codes and make it public so I can check it out.
+ 1
it worked fine, it output hello again 5 times. are you testing it on a mobile phones or web browser?
+ 1
Android or IOS? I tested it on android and Firefox it works. I don't know what could be the problem in your end.
0
I inputed your code into sololeq playground and it still gave me error. It didn't work
0
Where did u test it? On which editor?
0
I tested it and it told me
Uncaught type error. undefined is not a function
line 4
(line 4 is were the return statement is)
0
I tested it in SOLOLEARN play ground. Under javascript.
What do u think is wrong?
Why would a good code tell me Uncaught error
0
It's public
0
I am testing it on my mobile phone
0
I use android as well. I have been noticing the problem. But I don't know were its coming from
0
It's really frustrating