while trying to solve a "repeat a string exercise", I did some research and came across the following link: https://www.w3resource.com/javascript-exercises/javascript-string-exercise-21.php In that link, the code below is presented as a method for repeating a string. However, I have a question about a line of code within that method.
function repeat_string(string, count)
{
if ((string == null) || (count < 0) || (count === Infinity) || (count == null))
{
return('Error in string or count.');
}
count = count | 0; // Floor count.
return new Array(count + 1).join(string);
}
console.log(repeat_string('a', 4.6));
console.log(repeat_string('a'));
console.log(repeat_string('a', -2));
console.log(repeat_string('a', Infinity));
In the above code, I do not understand what this line of code is saying:
count = count | 0; // Floor count.
does count = count | 0; // Floor count.
mean count is equal to zero after the floor count?
Thanks for your help!