2017年4月3日月曜日

開発環境

Head First JavaScript Programming (Eric T. Freeman (著)、Elisabeth Robson (著)、O'Reilly Media)の Chapter 2.(Going further - Writing Real Code)、How the while loop works の SHARPEN YOUR PENCIL(No. 1332) を取り組んでみる。

SHARPEN YOUR PENCIL(No. 1332)

コード(Emacs)

JavaScript

let location1 = 3,
    location2 = 2,
    location3 = 5,
    guess,
    hits = 0,
    guesses = 0,
    isSunk = false;

while (isSunk === false) {
    guess = prompt('Ready, aim, fire! (enter number from 0-6):');
    if (guess === location1 || guess === location2 || guess === location3) {
        hits += 1;
    }
}

0 コメント:

コメントを投稿

Comments on Google+: