Reputation: 110083
I have the following code in javascript:
var seasonDropdown = TVContainer.find('select.season').val()
if (seasonDropdown == "-1" || !seasonDropdown) {seasonDropdown = null}
Is there a way to combine these two into one line?
Upvotes: 1
Views: 56
Reputation: 7165
You could do the following:
var seasonDropdown = (TVContainer.find('select.season').val() == "-1" || !TVContainer.find('select.season').val()) ? null : TVContainer.find('select.season').val();
But honestly, you should prefer readability over a solution like this.
if you want a bit cleaner look instead, you could use this:
var seasonDropdown = TVContainer.find('select.season').val();
if (seasonDropdown == "-1" || !seasonDropdown) seasonDropdown = null;
Upvotes: 2