Skip to content

Latest commit

 

History

History
33 lines (27 loc) · 915 Bytes

File metadata and controls

33 lines (27 loc) · 915 Bytes

JavaScript Quiz

1. What is the simplest way to write the if expression?

Assume that the author intended for 'aye' to print if there is a majorityVote and it is not isVetoed.

let majorityVote = true
let isVetoed = false
// ...
if ((typeof majorityVote !== 'undefined' && majorityVote === true)
	&& (typeof isVetoed !== 'undefined' && isVetoed === false)) {
  console.log('aye')
} else {
  console.log('nay')
}

2. What two things will print to console?

Promise.resolve(42)
.then((a) => console.log(a))
.then((b) => console.log(b))

3. Sum only the even numbers.

Use .filter and .reduce to solve this.

const list = [/* mysterious array of numbers: 1, 3, 4 */]