I have a situation where I want to write something along the lines of this to check the page urls for a string.
url example 1 - http://something.com/else/apples
url example 2 - http://something.com/else/oranges
url example 3 - http://something.com/else/bananas
...
url example 10 - http://something.com/else/kiwis
pseudo code:
if(window.location.href.indexOf('apples')>-1)
{
alert('apples');
}
if(window.location.href.indexOf('oranges')>-1)
{
alert('oranges');
}
....
As you can see it looks rather ugly to have multiple if statements so I'm looking for some advice on how to achieve this using a single if statement or possible a switch case. I had an idea about an if statement with several 'OR' statements, but I'm not sure if that's the best way of going about with this.
Thank you
ifs at all. Edit: Chris already made a one-liner solution.switchacts the same asifit is used to increase readability of code