- What are the types of the following expressions and what do they evaluate to, and why?
17
\number, because its only a number1 + 2 * 3 + 4
\expression, evaluates to 11 a number, because its a math expression800 / 80 / 8
\expression, evaluates to 1.25 a number, because its a math expression400 > 200
\boolean, evaluates to true, because you are using a comparison operator1 !== 1
\boolean, evaluates to false, because you are using a comparison operatortrue || false
\boolean, evaluates to true, because its a logical operatortrue && false
\boolean, evaluates to false, because its a logical operator20 % 6
\expression, evaluates to 2 a number, because its a math expression'a' + 'b'
\string, evaluates to ab, because you are adding two letters that each surrounded by ''
- What will the following return?
typeof 4
\numbertypeof 'hello'
\stringtypeof true
\boolean2 === 1 || 3 === 4
\false
- Create a truth table for the expression A || B.
For reference, here is a truth table for the expression A && B:
| A | B | A || B |
| true | true | true |
| false | true | true |
| true | false | true |
| false | false | false |
| A | B | A & B |
| true | true | true |
| false | true | false |
| true | false | false |
| false | false | false |
- Create a truth table for the expression !A && !B.
For reference, here is a truth table for the expression A && !B:
| !A | !B | !A && !B |
| true | true | true |
| true | false| false |
| false| true | false |
| false| false| false |
| A | B | !B | A & B |
| true | true | false | false |
| false | true | false | false |
| true | false | true | true |
| false | false | true | false |
- Write a step-by-step evaluation for the following expression (remember order of operations):
2 + 3 * 2 + 1
. \2 + 3 * 2 + 1 \2 + 6 + 1 \8 + 1 \9
For reference, here is a exp of a step-by-step evaluation:
1 + 2 + 3 + 4
3 + 3 + 4
6 + 4
10
-
Write a step-by-step evaluation for the following expression (remember order of operations):
4 / 2 + 8 / 4
. \4 / 2 + 8 / 4 \2 + 2 \4 -
Write a step-by-step evaluation for the following expression:
'ca' + 'ter' + 'pi' + 'llar'
. \ 'ca' + 'tar' + 'pi' + 'llar' \ 'catar' + 'pi' + 'llar' \ 'catarpi' + 'llar' \ 'catarpillar' -
Write a step-by-step evaluation for the following expression:
2 * 4 === 8 && 'car' + 'pool' === 'carpool'
. \ 2 * 4 === 8 && 'car' + 'pool' === 'carpool' \ 8 === 8 && 'car' + 'pool' === 'carpool' \ 8 === 8 && 'carpool' === 'carpool' \ true