開発環境
- OS X Mavericks - Apple(OS)
- Safari, Firefox + Firebug, Google Chrome(Webプラウザ、プラグイン)
- BBEdit - Bare Bones Software, Inc. (GUI) , Emacs (CUI) (Text Editor)
- JavaScript (プログラミング言語)
Head First JavaScript Programming (Eric T. Freeman (著)、 Elisabeth Robson (著)、 O'Reilly Media )のChapter 2(Writing Real Code: Going further)、SHARPEN YOUR PENCIL(p.48)を解いてみる。
SHARPEN YOUR PENCIL(p.48)
コード(BBEdit, Emacs)
var result = '', location1 = 3, location2 = 4, location3 = 5, guess, hits = 0, guesses = 0, isSunk = false; guess = prompt('Ready aim, fire! (enter a number 0-6): '); if (guess < 0 || guess > 6) { result += 'Please enter a valid cell number!\n'; } else { guesses += 1; guess = parseInt(guess, 10); if (guess === location1 || guess === location2 || guess === location3) { hits += 1; } } result += 'guesses: ' + guesses + ', hits: ' + hits; print(result);
0 コメント:
コメントを投稿