Learn modern JavaScript

Conditional operator

Conditional (Ternary) Operator ‘?’ Conditional (Ternary) operator takes in three operands: a condition, question mark and an expression to execute if condition is truthy and an expression if condition is falsy. Syntax of the ternary operator: let variablename = condition ? value1 : value2; Condition is evaluated and if truthy, value1 is return otherwise value2. …

Conditional operator Read More »

JavaScript Variables

JavaScript variables In JavaScript, a variable is a named storage location that is used to hold a value. Variables are used to store data, such as numbers, strings, or objects, and to perform operations on that data. Here is an example of how to declare and initialize a variable in JavaScript: The The