console.log([...Array(100)].map((e,i)=>(++i%3?'':'fizz')+(i%5?'':'buzz')||i).join("\n"))
Another approach if you want to create an array is using the Array.from() method. This way you can combine the spread operator and the map together in one operation.
Array.from()
Array.from( { length: 100 }, (o, i) => `${++i % 3 ? "" : "Fizz"}${i % 5 ? "" : "Buzz"}` || i ).forEach((el) => console.log(el));
Needs fixing for "FizzBuzz"
Indeed! I fixed the code in the comment. Didn't pay too much attention to the description
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Another approach if you want to create an array is using the
Array.from()
method. This way you can combine the spread operator and the map together in one operation.Needs fixing for "FizzBuzz"
Indeed! I fixed the code in the comment. Didn't pay too much attention to the description