2014年9月8日月曜日

開発環境

Head First JavaScript Programming (Eric T. Freeman (著)、 Elisabeth Robson (著)、 O'Reilly Media )のChapter 10(Liberated functions: First Class Functions)、EXERCISE(p.445)を解いてみる。

EXERCISE(p.445)

コード(BBEdit, Emacs)

var checkNoFlyList = function (passenger) {
        return passenger.name === 'Dr. Evel';
    },
    checkNotPaid = function (passenger) {
        return !passenger.paid;
    },
    passengers = [ { name: "Jane Doloop", paid: true },
                   { name: "Dr. Evel", paid: true },
                   { name: "Sue Property", paid: false },
                   { name: "John Funcall", paid: true }],
    i,
    max,
    output = '',
    passenger;

for (i = 0, max = passengers.length; i < max; i += 1) {
    passenger = passengers[i];
    output += passenger.name + ': ' + checkNoFlyList(passenger) + ', ' +
              checkNotPaid(passenger) + '\n';
}

print(output);












						

0 コメント:

コメントを投稿