Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
An awkward iteration
//JavaScript-C24.2.0 (SpiderMonkey) print("Hello, world!") // A function that returns an iterator for a range of integers function rangeIter(first, last) { let nextValue = Math.ceil(first); return { next: function () { if (nextValue > last) throw StopIteration; return nextValue++; } }; } // A awkward iteration using the range iterator let r = rangeIter(1, 5); while (true) { try { print(r.next()); } catch (e) { if (e == StopIteration) break; else throw e; } }
run
|
edit
|
history
|
help
0
JS is_sorted
Javascript Closure
Viktor Schelochkov
JS exam part 2 - Moms
Time Waister
SKYIES
on_off
game
JS exam part 2 - Circumference
Star wars ep 3. limit