Building Abstractions with Functions - The Elements of Programming - Conditional Expressions and Predicates - statement、evaluate, response
Structure and Interpretation of Computer Programs: JavaScript Edition(Harold Abelson(著)、Gerald Jay Sussman(著)、Julie Sussman(著)、The MIT Press)のChapter 1(Building Abstractions with Functions)、1.1(The Elements of Programming)、1.1.6(Conditional Expressions and Predicates)、Exercise 1.1の解答を求めてみる。
入出力結果(Terminal, Zsh)
% node
Welcome to Node.js v16.15.0.
Type ".help" for more information.
> 10; // 10
10
> 5 + 3 + 4; // 12
12
> 9 - 1; // 8
8
> 6 / 2; // 3
3
> 2 * 4 + (4 - 6); // 6
6
> const a = 3
undefined
> const b = a + 1;
undefined
> a + b + a * b; // 19
19
> a === b; // false
false
> b > a && b < a * b ? b : a; // 4
4
> a === 4 ? 6 : b === 4 ? 6 + 7 + a : 25; // 16
16
> 2 + (b > a ? b : a); // 6
6
> (a > b ? a : a < b ? b : -1) * (a + 1); // 16
16
> %