Guards are fantastic! While your Javascript syntax is perhaps the most verbose, guards can also be written as follows:
//a variable to test withleta='a';//condition && resulta==='a'&&console.log('yes it does!');
You may notice this looks similar to the ternary operator. This is great for one-liners (like return codes 😉) but should not be used for complex / multi-line statements:
//a variable to test withleta='a';//condition && result// !! THIS WON'T WORK !!a==='a'&&(console.log('did this work?')console.log('no :('));
Guards are fantastic! While your Javascript syntax is perhaps the most verbose, guards can also be written as follows:
You may notice this looks similar to the ternary operator. This is great for one-liners (like return codes 😉) but should not be used for complex / multi-line statements:
replit.com/@omBratteng/guard-claus...