412-fizz-buzz

DevGod
Vtuber
class Solution { public static List<String> fizzBuzz(final int n) { List<String> myList = new ArrayList<String>(); int A = 1; while(A<=n){ if(A%3 == 0 && A%5 == 0){ myList.add("FizzBuzz"); } else if(A%3 == 0){ myList.add("Fizz"); } else if(A%5 == 0){ myList.add("Buzz"); } else{ myList.add(String.valueOf(A)); } A++; } return myList; }}
/** * @param {number} n * @return {string[]} */
var fizzBuzz = function(n) { let arr = []; let I = 0; while(I < n){ if( (I+1)%3 == 0 && (I+1)%5 == 0 ){arr[I] = "FizzBuzz";} else if( (I+1)%3 == 0 ){arr[I] = "Fizz";} else if( (I+1)%5 == 0 ){arr[I] = "Buzz";} else {arr[I] = ""+(I+1);} I++; } return arr;};