開発環境
- 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 8(Bringing it All Together: Building an app)、SHARPEN YOUR PENCIL(p.340)を解いてみる。
SHARPEN YOUR PENCIL(p.340)
- ship2, ship3
- C4, A0
- yes
- ship2
- no
コード(BBEdit, Emacs)
var ships = [{locations: ["31", "41", "51"], hits: ["", "", ""] }, {locations: ["14", "24", "34"], hits: ["", "hit", ""] }, {locations: ["00", "01", "02"], hits: ["hit", "", ""] }], ship1 = ships[0], ship2 = ships[1], ship3 = ships[2], locations, hits; locations = ship2.locations; print('Location is ' + locations[1]); // 24 hits = ship3.hits; if (hits[0] === 'hit') { print('Ouch, hit on third ship at location one'); } hits = ship1.hits; hits[2] = 'hits'; print(hits);
0 コメント:
コメントを投稿