Talk:100 doors: Difference between revisions

Invalid JavaScript solution
m (→‎An observation: Added comment on the number of doors.)
imported>MattDESTROYER
(Invalid JavaScript solution)
Line 125:
</pre>
But in the examples it goes to 100, and not to 10, that means it's calculating 1000 doors, and not 100 doors? [[User:Rainb|Rainb]] ([[User talk:Rainb|talk]]) 07:03, 21 July 2014 (UTC)
 
== Invalid JavaScript solution ==
 
ES6:
 
```
 
// Array comprehension style
[ for (i of Array.apply(null, { length: 100 })) i ].forEach((_, i) => {
var door = i + 1
var sqrt = Math.sqrt(door);
 
if (sqrt === (sqrt | 0)) {
console.log("Door %d is open", door);
}
});
 
```
 
JavaScript does not have array comprehension, this results in a syntax error... [[User:MattDESTROYER|MattDESTROYER]] ([[User talk:MattDESTROYER|talk]]) 00:29, 3 December 2023 (UTC)