AndyJarrett Code. Develop. Manage.

FizzBuzz in CFML

Reading an article on testing in interviews and it mentioned the Fizzbuzz test. If you haven't heard of this its simply:

Saw this ages ago and wanted to have a play around with this myself (without googling) and do in this in CFML. Well here it is.

for(var i=1; i <= 100; i++){ writeOutput("("&i&")"&((i%3)?"":"fizz") & ((i%5)?"":"buzz")&"<br>"); }

There is probably a way to get it shorter though without hitting search this is my effort.

Also tried this Javascript and managed to get it a bit more lightweight thanks to console.log

for(var i=1; i <= 100; i++){ console.log(i,(i%3)?"":"fizz", (i%5)?"":"buzz"); }