100 doors: Difference between revisions

Content added Content deleted
imported>Lacika7
mNo edit summary
(Javascript →‎ES6: Flagged example as working with SpiderMonkey after changing the console.log call to work with SpiderMonkey)
Line 7,444: Line 7,444:




{{works with|SpiderMonkey}}
<syntaxhighlight lang="javascript">// Array comprehension style
<syntaxhighlight lang="javascript">// Array comprehension style
[ for (i of Array.apply(null, { length: 100 })) i ].forEach((_, i) => {
[ for (i of Array.apply(null, { length: 100 })) i ].forEach((_, i) => {
Line 7,450: Line 7,451:


if (sqrt === (sqrt | 0)) {
if (sqrt === (sqrt | 0)) {
console.log("Door %d is open", door);
console.log("Door " + door + " is open");
}
}
});</syntaxhighlight>
});</syntaxhighlight>