Javascript
JavaScript Fundamentals -- Logical and Comparison Operators

Logical Operators -- Not 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.name
const dog = {
  breed: 'Labradoodle'
}
console.log(!dog.name);

// 2. What is the value of name?
let name = !!dog.name;
console.log(name);
name = !dog.name
console.log(name);

// 3. Provide a value for the ifStatement variable using the not operator and the name attribute so that you enter the if statement.
const ifStatement = !dog.name;
if (ifStatement) {
  dog.name = 'Max';
}
console.log(dog);

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

 

I finished! On to the next chapter