shared before
const range = function*(from, to, step = from > to ? -1 : 1) {
if (step < 0 ? from <= to : from >= to) {
return;
}
yield from;
return yield* range(from + step, to, step);
};
h = range(1, 10);
v = range(2, 5);
for (const x of h) {
for (const y of v) {
console.log(x,y);
}
}
But it returns:
1 2
1 3
1 4
My problem is that it works but when nested, it doesn't
Then, how would you do this OOF
this function will actually handle floats badly @TRGWII
Обсуждают сегодня