Yeah it's one way to do it but that still keeps the same if-else (or just no-return-statement) logic that we want to ideally get rid of. Here I'd also worry about the performance as if-else is costly and so is looping and here we'd have looping inside if-else. But I like this example — thank you!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
If you have more than one condition, why you just not using an array rather than or?
Yeah it's one way to do it but that still keeps the same
if-else
(or justno-return-statement
) logic that we want to ideally get rid of. Here I'd also worry about the performance asif-else
is costly and so is looping and here we'd have looping insideif-else
. But I like this example — thank you!