문제 링크 : Fizz Buzz
/**
* @param {number} n
* @return {string[]}
*/
var fizzBuzz = function(n) {
const arr = new Array(n).fill(0)
arr.forEach( (e,i) => {
arr[i] = `${i+1}`
if( (i+1)%3 === 0 ) arr[i] = "Fizz"
if( (i+1)%5 === 0 ) arr[i] = "Buzz"
if( (i+1)%15 === 0 ) arr[i] = "FizzBuzz"
})
return arr
};
/**
* @param {number} n
* @return {string[]}
*/
var fizzBuzz = function(n) {
return new Array(n).fill(0).map((a, i) => (++i % 3 ? '' : 'Fizz') + (i % 5 ? '' : 'Buzz') || '' + i);
};