+ 2

JS return and if.

Okay in this core I’m trying to avoid if statements by using return. f(x){ return if (x > 5) } f(4){do this) // false f(9){do that) // true Instead of if (4 > 5){ do this) if (9 > 5){do that) if (66 > 5){blabla). I’m trying to simply / make the code shorter by getting rid of repeated ifs. But I think I’m way off on what. So what would be the correct way of using the return and if statement to make it shorter...?. https://code.sololearn.com/WC9SL4fY6EPS/?ref=app

28th Sep 2020, 4:24 AM
Ginfio
Ginfio - avatar
0 odpowiedzi