Questions mark is part of the ternary operator
?:
, that is a different version of the if
statement.You can use the ternary operator to select a value by some condition:
const array = [ 1, 2, 3 ];
const result = array.includes(2) ? 'Two is in the array' : 'Two is not in the array';
console.log(result); // Two is in the array