scrimba
JS Deep Dive
Types & Conditionals
How to Shorten Conditionals with Ternaries
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

How to Shorten Conditionals with Ternaries
AboutCommentsNotes
How to Shorten Conditionals with Ternaries
Expand for more info
index.js
run
preview
console
const isAuthenticated = false;
let cartItemCount = 0;

if (isAuthenticated) {
// add item to cart
cartItemCount = 1;
} else {
// tell user to login
console.log("Please log in!");
}
Console
index.html
-13:26