const tasks = 3;
const status = tasks > 0 ? 'Activ' : 'Gol';
console.log(status);tasks > 0 is true, so status receives “Activ”.
LESSON 20 OF 50
Use condition ? value1 : value2 for a short choice.
The conditional operator evaluates the condition before ?. When it is truthy, it returns the first expression; otherwise it returns the expression after :.
const tasks = 3;
const status = tasks > 0 ? 'Activ' : 'Gol';
console.log(status);tasks > 0 is true, so status receives “Activ”.
const status = 'Activ';The hard-coded value does not demonstrate a choice between two outcomes.
Declare status with a conditional operator based on tasks > 0 and print status.
Run the code to see the result.The conditional expression produces the value assigned to status, and the console confirms the selected branch.
ANALYSIS REQUEST
The initial discussion is without obligation. You receive an honest recommendation, suitable stages and the factors that affect price.