開発環境
- OS X Mavericks - Apple(OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Safari、Firefox + Firebug (Webプラウザ、プラグイン)
- JavaScript (プログラミング言語)
- jQuery (JavaScript Library)
『初めてのJavaScript 第2版』(シェリー・パワーズ著(Shelley Powers著)、武舎 広幸+武舎 るみ訳、オライリージャパン、2009年、ISBN978-4-87311-425-5) の3章(演算子と文)、練習問第3-1、3-2、3-3、3-4.を解いてみる。
その他参考書籍
練習問第3-1、3-2、3-3、3-4..
コード(BBEdit)
var result = '',
a = 37,
b = 3,
c = 18,
exp = $('#t0').val(),
one = parseInt($('#t1').val(), 10),
two = parseInt($('#t2').val(), 10),
three = parseInt($('#t3').val(), 10),
i;
result += '1.\n';
result += (a - b) % 3 / 2 * (4 + c) - 3;
result += '\n2.\n';
switch (exp){
case 'one':
case 'two':
result += 'OK';
break;
case 'three':
result += 'OK2';
break;
default:
result += 'NONE';
}
result += '\n3.\n';
if (one === 33 && two <= 100 && three >0){
result += 'ifコードブロック実行';
}
result += '\n4.\n';
for (i = 11; i < 20; i+= 1){
result += i + '\n';
}
result += '5.\n';
i = 19;
while (i > 10){
result += i + '\n';
i -= 1;
}
$('#pre0').text(result);
3-2.3-3.
0 コメント:
コメントを投稿