scrimba
The Ultimate JavaScript Bootcamp
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 isAuthenticatedUser = false;
let cartItemCount = 0;
if (isAuthenticatedUser) {
// add item to cart
cartItemCount = 1;
} else {
// tell user to login
console.log("Please log in!");
}
Console
index.html
-12:32