Ваш код дает следующий результат:
![Code from Question](https://i.stack.imgur.com/d1L8e.png)
Because not resetting the var s
inside the outter iteration.
Instead, you may do:
for (let i = 0; i < 5; i++) {
let s = '';
for (let j = 0; j < 10; j++) {
s += '*';
}
s += '\n';
console.log(s);
}
, который даст ожидаемый результат.