Quantcast
[ 3 / biz / cgl / ck / diy / fa / g / ic / jp / lit / sci / tg / vr / vt ] [ index / top / reports / report a bug ] [ 4plebs / archived.moe / rbt ]

Due to resource constraints, /g/ and /tg/ will no longer be archived or available. Other archivers continue to archive these boards.Become a Patron!

/g/ - Technology

Search:


View post   

[ Toggle deleted replies ]
>> No.69472627 [View]
File: 35 KB, 251x895, best solution.jpg [View same] [iqdb] [saucenao] [google] [report]
69472627

>>69468679
Just write a fizzbuzz generator

let fizBuzFactory = (lines) =>{
let fizBuzz = ""
let puts = (s) => {fizBuzz += s + "\n"}
puts("int main(){")
puts(" for(int i = 0; i < "+lines+"; i++){")
for(let i = 1; i < lines; i++){
puts(" if(i == "+i+")")
if(i % 15 == 0)
puts(" puts(\"FizzBuzz\");")
else if(i % 3 == 0)
puts(" puts(\"Fizz\");")
else if(i % 5 == 0)
puts(" puts(\"Buzz\");")
else
puts(" puts(\""+i+"\");")
}
puts(" }")
puts("}")

return fizBuzz
}



Navigation
View posts [+24] [+48] [+96]