Javascript Fundamentals: Boolean Logic

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/10

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

11 Terms

1
New cards

Write down what the following statements will return: 2 == "2";

true

2
New cards

Write down what the following statements will return: 2 === 2;

true

3
New cards

Write down what the following statements will return: 10 % 3;

1

4
New cards

Write down what the following statements will return: 10 % 3 === 1;

true

5
New cards

Write down what the following statements will return: true && false;

false

6
New cards

Write down what the following statements will return: false || true;

true

7
New cards

Write down what the following statements will return: true || false;

true

8
New cards
term image
  1. The code should console.log "Keep it up!" because the value of the isLearning variable is truthy. That means the code inside of the if {} will be evaluated and not the else {}

  2. Since true is a "truthy" value, we can let the if statement turn the expression into a value that is true or false. True will evaluate into a truthy value

9
New cards
term image
  1. The code should console.log "Third" because the thirdVariable is truthy. Even though the firstVariable is falsey, the or statement is only looking for one truthy statement.

  2. The value of firstVariable is undefined. Variables that are not assigned to any value are assigned to the value undefined

  3. No, undefined is a falsey value

  4. No, empty strings are falsey values as well

  5. Yes, all numbers except for 0 are truthy

10
New cards
  • Research Math.random here and write an if statement that console.log's "Over 0.5" if Math.random returns a number greater than 0.5. Otherwise console.log "Under 0.5".

knowt flashcard image
11
New cards
  • What is a falsey value? List all the falsey values in JavaScript.

A falsey value in JavaScript is a value that evaluates to false when encountered in a Boolean context. The falsey values include: false, 0, -0, 0n, "", null, undefined, and NaN.