On day 14, I learned the basics of conditional statements and loops and functions.

1. Conditional statements

< 1 > if statements

Use this statement to execute code only if the specified condition is true.

<2>if… Else statements

Code is executed when the condition is true (after if) and other code is executed when the condition is false (after else).

<3>if… else if… Else statements

Select one of multiple code blocks to execute

Grammar:

Condition1 (condition1) {condition1 is true} else if (condition2) {condition2 is true} else {condition1 and condition2 are not true }

2. Switch statement

Select one of the multiple code blocks to execute

Grammar:

switch(n) 

{case 1: execute code block 1;

             break;

Case 2: Execute code block 2;

             break; 

Default: code executed at different times from case 1 and case 2

}

3. For loop

Loop a code block a certain number of times

Grammar:

For (statement 1; Statements 2; Statement 3) {executed code block}

4. For /in loop

Loop over the properties of an object

5. While loop

Loops the specified code block when the specified condition is true

6. Do /while loop

The loop executes a block of code once before checking if the condition is true, and then repeats the loop if the condition is true.

Today, I did 99 times table and 100 yuan to buy 100 chickens, and tried to know the traversal cycle. I will write a summary of the knowledge point about the function tomorrow.