Answer the question
In order to leave comments, you need to log in
Why isn't multiple spaces added to a string in JavaScript?
The function should return a string with a random number of spaces. During debugging, I determined that only the first space is added to the temporary string (the space is passed as a function parameter). Other additions do not change the line.
function repeatStr (str) {
var num = getRandomInt(1, 5);
var tmp = '';
for(var j = 0; j < num; j++)
tmp += str;
return tmp;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question