開発環境
- OS X Yosemite - Apple (OS)
- Emacs (Text Editor)
- JavaScript (プログラミング言語)
- SpiderMonkey (JavaScript engine)
Data Structures and Algorithms With Javascript (Michael McMillan(著)、O'Reilly Media)のChapter 2(Arrays)、Exercises 2.(No. 1820)を解いてみる。
Exercises 2.(No. 1820)
JavaScript(Emacs)
var words = ['scheme', 'c', 'javascript', 'scala', 'python'],
i,
max;
print(words);
print('forword--------------------------------------------------');
for (i = 0, max = words.length; i < max; i += 1) {
print(words[i]);
}
print('backword--------------------------------------------------');
for (i = words.length - 1; i >= 0; i -= 1) {
print(words[i]);
}
出力結果(Terminal, shell, SpiderMonkey)
$ js sample2.js
scheme,c,javascript,scala,python
forword--------------------------------------------------
scheme
c
javascript
scala
python
backword--------------------------------------------------
python
scala
javascript
c
scheme
$
0 コメント:
コメントを投稿