Reputation: 587
Hello I have this line right now with an if else statement and I'm trying to convert it to if else if else statement.
This is coffescript
_index = if $product.find('.dot.active').index() then 0 else 1
Any help will be appreciated.
Upvotes: 1
Views: 64
Reputation: 8343
Actually, an alternative to using if that achieves the same thing, arguably clearer, would be to use the switch statement like this:
_index = switch $product.find('.dot.active').index()
when false then 0
when 1 then 2
else 3
Upvotes: 0
Reputation: 46
_index = if $product.find('.dot.active').index() then 0 else if 1 then 2 else 3
I think this is what you're looking for.
Upvotes: 2
Reputation: 180787
_index = if $product.find('.dot.active').index()
then 0
else
if <some other condition> then <some other result> else <yet another result>
Upvotes: 3