Categorie: Tutti - conditional - functions - operators - math

da Brenda De la Cruz mancano 6 anni

437

JavaScript

JavaScript

Validación de datos

del cliente

del servidor

puede validar la entrada numérica

The else if Statement

if (condition1) { // block of code to be executed if condition1 is true } else if (condition2) { // block of code to be executed if the condition1 is false and condition2 is true } else { // block of code to be executed if the condition1 is false and condition2 is false }

The else Statement

if (condition) { // block of code to be executed if the condition is true } else { // block of code to be executed if the condition is false }

The if Statement

if (condition) { // block of code to be executed if the condition is true }

Comparing Different Types

age = Number(age); if (isNaN(age)) { voteable = "Input is not a number"; } else { voteable = (age < 18) ? "Too young" : "Old enough"; }

Conditional (Ternary) Operator

variablename = (condition) ? value1:value2

How Can it be Used

if (age < 18) text = "Too young";

Comparison Operators

true

Subtema

.abs()

Math.abs(-4.7); // returns 4.7

.sqrt ()

Math.sqrt(64); // returns 8

.pow()

Math.pow(8, 2); // returns 64

.round(x)

Math.round(4.7); // returns 5

JavaScript

Validation

if else and else if

Comparison and Logical Operators

Math Object