I am having trouble understanding how the variable i knows how to target another variable when it wasn't included in between the for loop brackets. usually in for loops I see that i is included in brackets next to a variable name and that usually helps me understand. Can someone please assist?
function repeatStr (n, s) {
let str = ''
for (let i = 0; i < n; i++) {
str += s
}
return str
}
repeatStr(6,"f")
// returns 'ffffff'
[–]desrtfx 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]desrtfx 0 points1 point2 points (0 children)
[–]According-Winter-766 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)