javascript conditional
condition ? ifTrue : ifFalsecondition ? doThisIfTrue : doThisIfFalse
1 > 2 ? console.log(true) : console.log(false)
// returns false//ternary operator example:
var isOpen = true; //try changing isOpen to false
var welcomeMessage = isOpen ? "We are open, come on in." : "Sorry, we are closed.";
var age=20;
if (age < 18) {
console.log("underage");
} else {
console.log("let em in!");
}if (x === 5 || x === 8)
console.log("x is eaqual to 5 OR 8")// example:
age >= 18 ? `wine` : `water`;
// syntax:
// <expression> ? <value-if-true> : <value-if-false>
Also in JavaScript:
- javascript regex Zero or one occurrence
- angular input press enter
- format a date moment
- change view port of svg with javascript
- json search javascript
- Javascript program printing the lyrics to the 99 bottles of beer song web
- javascript assign value to input using name
- fetch js
- document queryselectorall and map javacript
- can you get reinfected with the coronavirus
- react native init project
- selector id jquery but is variable
- remove array elements javascript
- oscar toledo chess javascript
- set navigation drawer to open by default react native
- react redux
- javascript canvas reset transform
- check for balanced parentheses in javascript
- javascript get file extension from string
- how use modal in login button click in react js
- export multiple functions react
- cli run js
- how to clear array in javascript
- monk find fields