I have the following function. The problem I have is that I can not get the var c
of the function contains
. Then the console.log(c)
that I have in my if
does not work. How can I change contains
to make this work?
function contains(target, pattern) {
var value = 0;
pattern.forEach(function(word) {
value = value + target.includes(word);
});
var c = value;
return (value === 1)
}
if (contains(a, b)) {
console.log(a);
console.log(c);
} else {
//false statement..do nothing
}