scrimba
Frontend Career Path
Essential JavaScript concepts
JS Mini Projects
The Ternary Operator for Complex Conditionals
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

The Ternary Operator for Complex Conditionals
AboutCommentsNotes
The Ternary Operator for Complex Conditionals
Expand for more info
index.js
run
preview
console
const exerciseTimeMins = 40

let message = ''

if (exerciseTimeMins < 30) {
message = 'You need to try harder!'
}
else if(exerciseTimeMins < 60) {
message = 'Doing good!'
}
else {
message = 'Excellent!'
}

// const message = exerciseTimeMins < 30 ? 'You need to try harder!' : 'Doing good!'

console.log(message)
Console
"Doing good!"
,
/index.html
-3:05