How to fulfill 2 or more conditions, and not one in a shortened version of if?
Kind. Is it possible to fulfill 2 or more conditions in a shortened version of if?
The question is incorrect.
To avoid looking for a comment:
I mean how to make it so that after the condition I can perform 2 actions, and not one? For example age & lt; 3? 'Hello how are you?' : 'Hai', 'Bai'
condition? (..., ..., ...): (...)Anonymous
let message = (age < 3) ? 'Здравствуй, малыш!' :
(age < 18) ? 'Привет!' :
(age < 100) ? 'Здравствуйте!' :
'Какой необычный возраст!';
This is not a shortened version, but a ternary operator.
Do one ternary operator nested within another.
But this is often not recommended.
There is no benefit, and the readability of the code deteriorates.Anonymous
To place the code, please use CodePen or similar tool. Thanks you!