I need to create a function that gets an array and compare it to a string , outside the array , returning true
if, and only if, at least twice the string exists outside the array . The output should look like this:
Str2(["a", "b", "a", "c"], "c");
//=> "false"
Str2(["a", "b", "a", "c"], "a");
//=> "true"
The function below should do this, but always returns false ".
var Str2 = function(strs, str){
var i, a = 0;
for(i=0; strs.length; i++){
if (str == strs[i] ) {
a = a + 1;
if (a > 1) {return "true";}
else {return "false";}
}
}
}