JavaScript Jeśli skrót
condition ? doThisIfTrue : doThisIfFalse
1 > 2 ? console.log(true) : console.log(false)
// returns false
Adventurous Ant
condition ? doThisIfTrue : doThisIfFalse
1 > 2 ? console.log(true) : console.log(false)
// returns false
isLoggedIn ? "Logout" : "Login";
const answer = x > 10 ? "greater than 10" : "less than 10";
// or
if (something)
return;
// other code here
pet = pets.find(pet => pet.type ==='Dog' && pet.name === 'Tommy');
console.log(pet); // { type: 'Dog', name: 'Tommy' }