In javascript the following conditionals can be used within any code depending on any option that we must determine:
Example:
Imagine the case that we want to buy a hotel night, whose price is €30, and we have €50.
If our amount of money is greater than €30 we can buy the hotel night, otherwise we will not be able to do so.
const mymoney = 50;
if(mymoney > 30){
console.log('Hotel night purchased');
} else if(mymoney == 30){
console.log('Hotel night purchased');
} else {
console.log('It has not been possible to buy the hotel night');
}
This example can also be written in JavaScript by using the Ternary Operator:
const mymoney = 50;
(mymoney > 30) ? console.log('Hotel night purchased') : console.log('It has not been possible to buy the hotel night');
Tips on SEO and Online Business
Next Articles
Previous Articles