js if
If - Else Statements
if (condition) {
// what to do if condition is met
} else {
// what to do if condition is not met
}
if(a == 'value'){
doSomething();
if(b == 'another value'){
doAnotherThing();
}
}var age=20;
if (age < 18) {
console.log("underage");
} else {
console.log("let em in!");
}const number = (Math.random() - 2.5) * 5;
if (number < 0) {
console.log('Number is negative');
}
if (number = 0) {
console.log('Number is zero');
}
if (number > 0) {
console.log('Number is positive');
}if (5 < 10) {
console.log("5 is less than 10");
} else {
console.log("5 is now bigger than 10")
}/* Shorten if-else by ternary operator*/
const go = "yes"
let race = null
race = go === "yes" ? 'Green Light' : 'Red Light';
Also in JavaScript:
- js date remove am and pm
- picker change event react native
- js add item to array
- javascript multiple startswith
- Selectores de jQuery
- javascript stop execution
- how to install node js in ubuntu
- java serialize object to json
- how to read file extension in a folder in node js
- add coustom handlechange fprmik
- javascript convert in a string the items of an array
- how to take create array using jquery
- age calculator javascript
- How to Submit Forms and Save Data with React.js
- how to create react app in vs code
- js use await in synchronous method
- cadena promesas javascript
- vue js wathc
- jquery check if checkbox is not checked
- js propagation stop
- How to change htm h1 from nodejs
- javascript full screen div
- how to get session value using javascript
- react function called last state