Anonymous user
General FizzBuzz: Difference between revisions
→ES6: Undo revision 272502 by Hout (talk) reduce used over map/join to reduce iterations, but fair. enumFromTo is uncommon, unclear (enums?), and semantically incorrect (through, not to)
(→JS ES6: Got it – so the other fold is better understood as a map, with intercalated '\n'. Simplified here.) |
|||
Line 1,340:
'use strict';
//
const
Array.from({
length:
}, (_, i) =>
const defaultRules = Object.freeze([
Line 1,355 ⟶ 1,354:
// fizzBuzz :: Int -> [[Int, String]] -> String
const fizzBuzz = (max, rules = defaultRules) =>
rules.reduce((words,
)
) + '\n', ''
).slice(0, -1)
console.log(fizzBuzz(20));
|