JavaScript | 자바스크립트 | CONTROL FLOW 셋

JavaScript | 자바스크립트 | CONTROL FLOW 셋

More on Control Flow in JS | Codecademy
When we tell a program what order to do things in, we're using something called control flow. You already know about 'if' statements, but in this course, we'll expand our knowledge!


Three. Logical Operators
10/14 Overview
File1 _ script.js
// Complete lines 3 and 4!

var iLoveJavaScript = true;

var iLoveLearning = true;

if(iLoveJavaScript && iLoveLearning) {

  // if iLoveJavaScript AND iLoveLearning:
  console.log("Awesome! Let's keep learning!");
} else if(!(iLoveJavaScript || iLoveLearning)) {
  // if NOT iLoveJavaScript OR iLoveLearning:
  console.log("Let's see if we can change your mind.");
} else {
  console.log("You only like one but not the other? We'll work on it.");
}

11/14 And
File1 _ script.js
// Declare your variables here!
var hungry = true;
var foodHere = true;

var eat = function() {

  // Add your if/else statement here!
  if (hungry && foodHere) {
      return true;
  } else {
      return false;
  }
};

eat();

12/14 Or
File1 _ script.js
// Declare your variables here!
var tired = true;
var bored = false;

var nap = function() {

  // Add your if/else statement here!
  if (tired || bored) {
      return true;
  } else {
      return false;
  }
};

nap();

13/14 Not
File1 _ script.js
// Declare your variables here!
var programming = false;

var happy = function() {

  // Add your if/else statement here!
  if (!programming) {
    return true;  
  } else {
    return false;  
  }
};

happy();

14/14 Review
File1 _ script.js

Next Course: Code Your Own Adventure 2!

| JavaScript has three logical operators: and( && ), or( || ), and not( ! ).

| 서울역. 밖은 지금 너무 덥습니다만, 기차 안은 시원해서 흐뭇.