Change < 101 to
Is it bad? If yes why?
>What style guidelines do you follow
>just fuck my shit up senpai
while(i < max){
var s;
i % 15 ? s = "FizzBuzz" : i % 5 ? s = "Fizz" : i % 3 ? s = "Buzz" : s = i;
Console.log(s);
i++;
}
Am i good at js yet?
>what is 'else' execution order
var s outside of while... ofc... fuck
s = i % 15 ? : ...
would be cleaner also. Would that do any difference though? In efficiency
OP's else only applies to if(i%5 == 0)
public static void doFizzBuzz() {
boolean a, b;
for (int i = 0; i
>that logic
>using Java 7
>in 2014 + 4
use streams!
public static void main(String[] args) {
System.out.println(fizz());
}
public static List fizz() {
return IntStream.range(1, 101).mapToObj(FizzBuzz::getFizzBuzzString).collect(toList());
}
public static String getFizzBuzzString(int i) {
String string = "";
if (i % 3 == 0)
string += "Fizz";
if (i % 5 == 0)
string += "Buzz";
if (string.isEmpty())
return i + "";
return string;
}
program FizzBuzz;
var i:integer;
s:string;
begin
for i:=1 to 100 do
Begin
s:='';
If i mod 3 = 0 then s:=s+'Fizz';
If i mod 5 = 0 then s:=s+'Buzz';
if s='' then writeln(i) else writeln(s);
End;
end.