Having recently started using Angular, I'm encountering an issue with retrieving a return value from a function that I have implemented within another one.
private validateKeyterm(): boolean {
const val = this.form.value.term;
if (this.selectedTermType == 'keywords') {
// filter out data
this.keywordTemp.filter(function (d) {
if((d.term.toString().indexOf(val) !== -1 || !val) == true){
console.log("keytemp: true");
return true;
}
}) ;
} else {
this.profanityTemp.filter(function (d) {
if((d.term.toString().indexOf(val) !== -1 || !val) == true){
console.log("profanity: true");
console.log("true");
return true;
}
else{ return null;}
});
}
console.log("false");
return false;
}
Unfortunately, I keep receiving the return value "fail" consistently when executing this function. Can anyone assist me in finding a solution to ensure that the "validateKeyterm" function accurately returns "true" in certain cases?