1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

node.jsでズンドコゲッター

Last updated at Posted at 2016-05-31

概要

paizaのnode.jsでズンドコゲッターやってみた。

実際

サンプルコード

process.stdin.resume();
process.stdin.setEncoding('utf8');

var http = require('http');

var i = 0;
var j = 0;
var str = "";
function zundoko(callback) {
    var URL = 'http://ohijs0.paas.jp-e1.cloudn-service.com/zundoko';
    http.get(URL, (res) => {
        var body = '';
        res.setEncoding('utf8');
        res.on('data', (chunk) => {
            body += chunk;
        });
        res.on('end', (res) => {
            callback(body);
        });
    }).on('error', (e) => {
        console.log(e.message);
    });
}
function kiyosi() {
    if (j < 1)
    {
        zundoko(function(response) {
            str += response + " ";
            if (response == "ドコ")
            {
                if (i == 4) 
                {
                    j = 1;
                }
                else
                {
                    i = 0;
                }
            }
            else
            {
                i++;
            }
            kiyosi(response);
        });
    }
    else
    {
        str += "キ・ヨ・シ!";
        console.log(str);
    }
}
kiyosi();
1
0
0

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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?