The ternary could have been more readable if each part of the expression had its own line, but other than that, it's not particularly difficult to read: is thus truthy? Then do this, else is the next element truthy? Then do this, else...
I honestly fail to see how a function with so many nested returns is more readable. I could see a case for a bunch of else if statements, if one is not used to reading ternaries. But this function within a function within a function just seems more complicated to read to me.
For me, converting the ternary expression to a function within a function was far more readable.
I had multiple condition for every nested ternary expression and it was hell.
Think about if you have to add some code for one of the nested conditions, for me it's just more easier to have it like that.
It's also not mandatory to leave it like that, I find it easy to refactor the function and not a nested ternary that is on the same line.
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.
The ternary could have been more readable if each part of the expression had its own line, but other than that, it's not particularly difficult to read: is thus truthy? Then do this, else is the next element truthy? Then do this, else...
I honestly fail to see how a function with so many nested returns is more readable. I could see a case for a bunch of
else if
statements, if one is not used to reading ternaries. But this function within a function within a function just seems more complicated to read to me.For me, converting the ternary expression to a function within a function was far more readable.
I had multiple condition for every nested ternary expression and it was hell.
Think about if you have to add some code for one of the nested conditions, for me it's just more easier to have it like that.
It's also not mandatory to leave it like that, I find it easy to refactor the function and not a nested ternary that is on the same line.