This is the second or third time I've seen it.
There is iteration between a and b?
What if there will be more than two numbers?
Why not Math.min(a, b); ?
Please explain this write-up -> return a < b ? a : b;
Rozwiązane
Komentarze (1)
- Popularne
- Najnowsze
- Najstarsze
Musisz się zalogować, aby dodać komentarz
Thomas
24 grudnia 2022, 07:23rozwiązanie
That's called ternary operator and is similar to an if else with an assignment.
And of course you can use Math.min() instead. Just guess how this is implemented ;)
If you have more than two numbers, then you do it like you would using Math.min() or you nest ternary operators
+2