Javascript
JavaScript Fundamentals -- Logical and Comparison Operators

Logical Operators -- And Exercise Review

Mute
Current Time 0:00
/
Duration Time 0:00
Loaded: 0%
Progress: 0%
Stream TypeLIVE
Remaining Time -0:00
 
PRO

Here's one possible solution to the exercise:

// 1. dog && dog.breed
const dog = {
  breed: 'Labradoodle'
}
console.log(dog && dog.breed);

// 2. What is the value of name?
const name = dog && dog.name;
console.warn(dog && dog.name);

// 3. Provide values for val1 and val2 so that you enter the if statement.
const val1 = 'Hello';
const val2 = 'World';
if (val1 && val2) {
  console.log('You made it into the if statement')
}

Fork this StackBlitz project to see the answer key from this video.

 

I finished! On to the next chapter