Generate the first 1000 FizzBuzz words and numbers. Every number divisible by three is a “Fizz”, fives are a “Buzz”, and both together are the name of the game. It’s “FizzBuzz”!
export const take = []
export const make = () => {
const fizbuzz = Array.from(
{ length: 1000 },
(_, i) => (++i % 3 ? "" : "Fizz") + (i % 5 ? "" : "Buzz") || i
)
const modulus = 5
const columns = ["Numbers", "Result"].concat(Array(modulus - 1))
const value = fizbuzz.reduce((m, e, i) => {
if (i % modulus === 0) m.push([`**${++i}–${i + modulus - 1}**`])
m.at(-1).push(e > 0 ? e + " " : `_${e}_`)
return m
}, [])
return [
{
type: "table",
columns,
value,
},
]
}