FizzBuzz

Sometimes you just want to cram something into a single expression rather than write a code block with multiple instructions. Don’t you?

JavaScript

(n=>new(Array)(n).join(0).split(0).map((_,v)=>v+1).map(v=>v%15==0?'FizzBuzz':v%3==0?'Fizz':v%5==0?'Buzz':v))(30)

PowerShell

1..30|%{if($_%15-eq0){"FizzBuzz"}elseif($_%5-eq0){"Buzz"}elseif($_%3-eq0){"Fizz"}else{$_}}

Enterprise

For a better example of how to do this, please see FizzBuzz Enterprise Edition

Leave a Reply

Your email address will not be published. Required fields are marked *