I have an Ajax request that can return more than one valid value, so i am using the “OR” operator to analyse the response, like this:
if(json.reply == "d" || json.reply == "e" || json.reply == "i" || json.reply == "j" || json.reply == "k" )
My real code has more comparisons yet, so is there a more readable and elegant sintaxe in Javascript to write this? Something like the SQL “IN” operator:
if( json.reply IN ("d", "e", "i", "j", "k") )
Thanks for any suggestions!
Switch statement is another possible way: