I have the following function. The problem I'm having is that I can't get the var out c
of the function contains
. So the console.log(c)
one I have on me if
doesn't 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
}