View on GitHub

reading-notes

Chapters:

  1. Chapter 3: “Lists” (pp.62-73)
  2. Chapter 13: “Boxes” (pp.300-329)
  3. Chapter2: “Basic JavaScript Instructions”
  4. chapter 4: “Decisions and Loops” from switch statements

Chapter 3: “Lists”

img

2. Chapter 13: “Boxes”

img

For example, we can take this sample CSS code below;

div { border-style: solid; border-color: blue; }

This div does not have padding defined, as such, you have the output shown in the image below.

Chapter2: “Basic JavaScript Instructions and loops”

here are situations when we want to run the code at different conditions, such as, if one condition applies run a particular code, if another condition applies another code is run. This is prioritized with “if” and “else if” conditionals as follows:

  `function getColor(phrase){
   if (phrase === "stop"){
   console.log("red");
   } else if (phrase === "slow"){
   console.log("yellow");
   } else if (phrase === "go"){
   console.log("green");
  } else {
   console.log("purple");
   }
   }` * The switch statement  is used to perform different actions based on different conditions.  Syntax:

  ` switch(expression) {
    case x:
      // code block
    break;
   case y:
     // code block
     break;
  default:
    // code block
    }`

This is how it works:

  1. The switch expression is evaluated once.
  2. The value of the expression is compared with the values of each case.
  3. If there is a match, the associated block of code is executed.
  4. If there is no match, the default code block is executed.

img