I'm using indexOf
to check a JSON twitter feed for certain strings. I want to have the ability to have multiple strings trigger the same event.
I wrote a switch that works if you're only looking for a single property in the array, but can't find a way to do this.
My first thought was trying
switch(true) {
case tweetContent.indexOf(Happy[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) !== -1:
// do a thing
break;
Which you can see in context below. Really lost here.
$.getJSON("tweets_JSON.php?count=5").done(function(json) {
console.log(json[0])
var Happy = ["hashtag1", "#hashtag2", "#hashtag3"];
var Sad = ["#hashtag4", "#hashtag5", "#hashtag6"];
var AgencyLife = ["#hashtag7", "#hashtag8", "#hashtag9"];
var tweetContent = json[0].text;
// Searchs text property of first tweet in feed for triggers
switch(true) {
case tweetContent.indexOf(Happy[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) !== -1:
console.log("horray!");
break;
case tweetContent.indexOf() !== -1:
console.log("boo!");
break;
case tweetContent.indexOf() !== -1:
console.log("boo!");
break;
case tweetContent.indexOf() !== -1:
console.log("boo!");
break;
case tweetContent.indexOf() !== -1:
console.log("boo!");
break;
default:
console.log("No Trigger Found. Light State unchanged.");
break;
}
});