I had a problem in ‘code wars‘ website and I couldn’t solve this Kata because I can’t use if statement or shortcut way, the kata said :
you have a function that has two argument and they are two numbers (a, b)if a > b return ‘a greater than b’ I need your help guys, thank you for everything.
I tried for three times, although I couldn’t find the solutions.
3
Answers
If you cannot use neither an explicit
if
statement nor a ternary operator, you can use an object as dictionary for the various cases, like:One way to do this is by using a ternary operator, which is a concise way to write conditional statements. possible solution,
How about this way ?