CoffeeScript版FizzBuzzWhizz
[fizz, buzz, whizz] = [3, 5, 7]
wordOf = (num) ->
if ~"#{num}".indexOf fizz
'Fizz'
else
['Fizz' unless num % fizz] + ['Buzz' unless num % buzz] + ['Whizz' unless num % whizz]
console.log (wordOf num) or num for num in [1..100]
2 回复
我讨厌这种强制缩进的语法…
有可能最后生成的js不是你想要的,也有可能使用姿势不对 哈哈