Babbage problem: Difference between revisions

Content deleted Content added
Hout (talk | contribs)
→‎{{header|JavaScript}}: Alternative approach using the Array constructor and filter method.
Hout (talk | contribs)
m →‎JS (ES6) Array constructor: Added a 'works with' tag, edited preamble
Line 806:
</lang>
====Array constructor====
 
{{works with|ES6}}
 
 
We can test Babbage's hypothesis that the number was a little under 100,000 by calling the Array.filter method on a sequence of squares of that order, generated by the Array constructor.
Line 811 ⟶ 814:
Both methods answer Babbage's question very quickly, but this Array constructor approach does turn out to be a little faster than the while loop above.
 
(The test section here is a translation of athe Haskell example on this page)
<lang JavaScript>(() => {