JavaScript base Teaching If conditional statement

Source: Internet
Author: User

If is one of the common syntax, the format is as follows

if (Coditon) statement1 (Else Statement2)

Where Coditon can be any expression, not even a true Boolean value, because JavaScript converts it automatically to a Boolean value.

Executes statement1 if the condition execution evaluates to TRUE, and executes the result Statment2 if the condition is false (else is not required if statement2 exists)

Each conditional statement can be a single line of code, or it can be a block of code. Here are the simple examples

The code is as follows:

var inumber = number (Prompt ("Please enter a digit between 5 and 100"));

if (isNaN (Inumber))

document.write ("Please confirm the number you entered.) ");

else if (Inumber > | | inumber < 5)

document.write ("The value you entered is not in range");

Else

document.write ("The value you entered is" + inumber);

Contact Us

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.