Ignoring the negativity surrounding this question, I'm stepping in to provide a solution.
Check out Demo here
Component
Make sure to convert all words to lowercase in both the goodWords
and badWords
arrays
obj = {
customer: [
{
threshold: 80,
sentence: 'Agent : Thank you for calling ABC company. My name is Ashley. How may I help you today?'
},
{
threshold: 40,
sentence: 'Customer : I am calling because I recieved a wrong bill. I just paid my phone bill two days ago.'
},
]
};
goodWords = ['thank', 'you', 'help', 'sorry', 'please'];
badWords = ['wrong', 'our', 'last', 'my'];
HTML
<div *ngFor="let item of obj.customer">
<span *ngFor="let word of item.sentence.split(' ')">
<span *ngIf="goodWords && goodWords.indexOf(word.trim().toLowerCase()) > -1; else redWord">
<span style="color: green">{{word}}</span>
</span>
<ng-template #redWord>
<span *ngIf="badWords && badWords.indexOf(word.trim().toLowerCase()) > -1; else other" style="color: red">
{{word}}
</span>
</ng-template>
<ng-template #other>
{{word}}
</ng-template>
</span>
<br><br>
</div>
All the necessary adjustments have been made within the HTML
itself. Hopefully, this resolves your concerns.