Answers for "question mark operator javascript"

2

question mark and colon in javascript

const isBlack = false;const text = isBlack ? 'Yes, black!' : 'No, something else.';console.log(text);// "No, something else."
Posted by: Guest on January-29-2020
4

javascript question mark

//This is what is called a 'Conditional operator'
let result = condition ? value1 : value2
//               ^^        ^^      ^^
let result =  1 == 2   ?  "YES" : "NO!"
console.log(result)  //output: "NO!"

//Basically a short form of an if-else statment
Posted by: Guest on March-11-2020
2

question mark in javascript

boolean statement ? true result : false result;

/*
For example, if we take this if statement:
*/
if (a > b) {
    result = x;
} else {
    result = y;
}
// can be also writen:
result = a > b ? x : y;
Posted by: Guest on October-20-2020
1

single if statement js true false

condition ? exprIfTrue : exprIfFalse
Posted by: Guest on July-23-2020
1

question mark operator javascript

voteable = (age < 18) ? "Too young":"Old enough"
//         condition  ?   if true  :  if false
Posted by: Guest on March-13-2021
2

question mark in javascript

(condition) ? {code for YES} : {code for NO}
Posted by: Guest on September-08-2021

Code answers related to "question mark operator javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language