Making decisions
1.[2p] Why does this course tell you to use === and never ==?
Why does this course tell you to use === and never ==?
2.[2p] What does 3 > 2 > 1 evaluate to? Write true or false.
What does 3 > 2 > 1 evaluate to? Write true or false.
3.[3p] Which of these values are falsy?
Which of these values are falsy?
Select all that apply
4.[3p] Access is allowed when loggedIn && !banned. What is the correct condition for access denied?
Access is allowed when loggedIn && !banned. What is the correct condition for access denied?
5.[2p] const x = 0; What number does console.log(x ?? 10) print?
const x = 0; What number does console.log(x ?? 10) print?
6.[2p] In user && user.age >= 18, short circuiting is what stops user.age being read when user is undefined.
In user && user.age >= 18, short circuiting is what stops user.age being read when user is undefined.
7.[2p] A parcel costs £3 under 1 kg, £5 under 5 kg, and £9 otherwise. Put the tests in the order the chain must use them.
A parcel costs £3 under 1 kg, £5 under 5 kg, and £9 otherwise. Put the tests in the order the chain must use them.
return 9;if (weight < 1) return 3;if (weight < 5) return 5;
Show the answer
b, a, c
8.[3p] Match each expression to the value it produces.
Match each expression to the value it produces.
0 || "d"
0 ?? 10
null ?? 10
0 == "0"
"" == "0"
the number 0
the string "d"
true
the number 10
false
Show the answer
0 || "d": the string "d" 0 ?? 10: the number 0 null ?? 10: the number 10 0 == "0": true "" == "0": false
9.[2p] What is the point of a guard clause?
What is the point of a guard clause?