Lab 1 Hard-Coded Quiz

1) Fill in the blank:

|| returns the first _____ value.
?? returns the first _____ value.

2) What would the console print?

let x = null;
let y = 5;
let z = null;
let cube = x ?? 10 * y ?? 10 * z ?? 2
console.log(cube)

3) What will the console print?

let cube = 1 ?? 2 && 3
console.log(cube)

4) Which of the following has a syntax error?

A)

let printError = e => { return e }

B)

let printError = e => e

C)

let printError = e, v => v

D)

let printError = (e, v) => { return v }

5) What does the console print?

let sum = (a, b) => {
console.log(a)
console.log(b)
return (a + b)
}
sum(1, 2)

6) What does this callback alert on success?

let callback = (value, on_success, on_failure) {
if (value != null) {
on_success()
} else {
on_failure()
}
}
callback(1, () => alert('Hooray!'), ()=>{alert('Boo!')})