LoginSignup
0

More than 5 years have passed since last update.

CoffeeScriptで非同期ズンドコキヨシ

Posted at

Promiseを使って非同期にズンドコキヨシしてみた。

参考: ズンドコキヨシまとめ

kiyoshi = (str = "")->
  new Promise (resolve) ->
    console.log w = ["ズン", "ドコ"][Math.random() * 2 | 0]
    if (str = str + w).match /(ズン){4}ド/
      console.log "キ・ヨ・シ!"
      resolve()
    else
      kiyoshi(str).then ->
        resolve()

kiyoshi()

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0