# Summary Nineth Day

Source: Internet
Author: User

Today, I learned about the IF statement, the switch statement, the For loop, and the while loop.

If statement: Single branch:

Format: if (conditional expression) {

Statement block

}　　　　　　　　　　　　！ Description: Executes a statement block when the conditional expression is set to get Boolean true

Dual Branching: format: if (conditional expression) {

Statement Block 1

}else{

Statement Block 2

}　　　　　　　　　　　　！ Note: If you get Boolean true when the conditional expression is set, the statement block 1 is executed but if the conditional expression is not true, the statement block 2 is executed.

Multi-branch: format: if (conditional expression 1) {

Statement Block 1

}else if (conditional expression 2) {

Statement Block 2

} else if (conditional expression 3) {

Statement Block 3

} else if (conditional expression N) {

Statement block N

}[else{

Statement block

}

The first step: first to determine whether the conditional expression 1 is true if it is set to a Boolean, the statement block 1 will be executed if not set to false will determine whether the conditional expression 2

The second step: it is suggested that the first step is not established on the basis of judging whether the conditional expression 2 is established if the Boolean true is set to execute the statement block 2 if it is not set to false will determine whether the conditional expression 3 is established

The third step: it is suggested that the second step is not established on the basis of the first to determine whether the conditional expression 3 is established if it is set up will execute the statement block 3 if it is not established, will then judge the next conditional expression

If the conditional expression above is not true and we write the else statement, then the statement block in the else is executed.

Else statements can be omitted without writing can be written according to the actual situation to decide

Switch

Format: switch (variable name) {

Case value 1:

Executing a statement block 1

Break

Case Value 2:

Executing a statement block 2

Break

Case Value 3:

Executing a statement block 3

Break

Case Value N:

EXECUTE statement block n

Break

Default

Default block of statements

Break

}

Description: Take the value of the variable name and each value in the case comparison is equal to the comparison if the comparison is established will execute the corresponding block of statements but it will go to find the corresponding block of statements after the break this keyword if not write it will continue to find the break keyword and will also be the following statement block output Until you find the break!

For loop:

Format: for (variable initialization; conditional expression; variable update) {

Loop body

}

The first step: variable initialization declares a variable and assigns it a value that executes only once.

Step two: Determine if the conditional expression is true if the conditional expression is set to execute the third step if the conditional expression is not true, exit the loop

Step three: Set up a second step to build on the basis of implementing the loop body

Fourth step: The variable is updated immediately to perform the second step to determine whether the conditional expression is true!

While loop:

Format: Variable initialization

while (conditional expression) {

Loop body

Variable update

}

Structure Description: Executes the loop body when the conditional expression is set!

Loop interrupt keyword: break, continue.

Break: When you encounter the Breaking keyword, the entire loop loop will not continue to execute!

Continue: When the Continue keyword is encountered, it interrupts the "this time" loop and continues the next cycle!

Window.prompt (Text,defaulttext)

A user Input dialog box will pop up

Text: Optional information for prompts

DefaultText: Optional default display of data

When the user clicks the OK button, they get a string type of data!

If the user does not fill in the data directly click the Cancel button to get null

parseint (variable name ): extracts an integer from a string when it encounters a non-numeric value, stops extracting if the first character of the string is not a value, return Nan directly

parsefloat (variable name): Extracts a floating-point number from a string when it encounters a character other than. It stops extracting if the first character of the string is not a value, it returns nan directly.

IsNaN (variable name): The variable name is converted to an automatic number type if the conversion is Nan then return true if it is not Nan and return false

Summary Nineth Day

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.