Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Array.from(Array(100)).forEach((_, index) => {
- let fizzBuzzStr = "";
- (index + 1) % 3 === 0 && (fizzBuzzStr += "Fizz");
- (index + 1) % 5 === 0 && (fizzBuzzStr += "Buzz");
- console.log(fizzBuzzStr || index + 1);
- });
- Array.from(Array(100))
- .reduce(
- ({ fizzBuzzes, fizzBuzzStr, j }, _, i) => (
- j % 3 === 0 && (fizzBuzzStr += "Fizz"),
- j % 5 === 0 && (fizzBuzzStr += "Buzz"),
- { fizzBuzzes: [...fizzBuzzes, fizzBuzzStr || j], fizzBuzzStr: "", j: ++j }
- ),
- { fizzBuzzes: [], fizzBuzzStr: "", j: 1 }
- )
- .fizzBuzzes.forEach(fizzBuzz => console.log(fizzBuzz));
- Array.from(Array(100))
- .reduce(
- ({ fizzBuzzes, fizzBuzzStr, j }, _, i) => {
- if (j % 3 === 0) {
- fizzBuzzStr += "Fizz";
- }
- if (j % 5 === 0) {
- fizzBuzzStr += "Buzz";
- }
- return {
- fizzBuzzes: [...fizzBuzzes, fizzBuzzStr || j],
- fizzBuzzStr: "",
- j: ++j
- };
- },
- { fizzBuzzes: [], fizzBuzzStr: "", j: 1 }
- )
- .fizzBuzzes.forEach(fizzBuzz => console.log(fizzBuzz));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement