function compareStr(arrays, str) { for (var ay of arrays) { if (ay == str) { return true; } } return false; } var arrays = ["abc", "ef", "hg"]; console.info(compareStr(arrays, "abc"));