開発環境
- 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 4(Putting Some Order in Your Data: Arrays)、SHARPEN YOUR PENCIL(p.149)を解いてみる。
SHARPEN YOUR PENCIL(p.149)
コード(BBEdit, Emacs)
var output = '',
scores = [60, 50, 60, 58, 54, 54, 58, 50, 52, 54, 48, 69, 34, 55, 51, 52,
44, 51, 69, 64, 66, 55, 52, 61, 46, 31, 57, 52, 44, 18, 41, 53,
55, 61, 51, 44],
highScore = - Infinity,
i,
max,
score;
for (i = 0, max = scores.length; i < max; i += 1) {
score = scores[i];
output += 'Bubble solution #' + i + ' score: ' + score + '\n';
if (score > highScore) {
highScore = score;
}
}
output += 'Bubbles tests: ' + max + '\n';
output += 'Highest bubble score: ' + highScore + '\n';
print(output);
0 コメント:
コメントを投稿