constructor(directory, wordsToIgnore) {
super();
this.directory = directory;
this.wordsToIgnore = wordsToIgnore;
}
log(message) {
const passedValidation = !this.wordsToIgnore.includes(message);
var today = new Date();
let logDate = `${today.getFullYear()}-${today.getMonth()}-${today.getDate()}.txt`;
fs.appendFile(this.directory + logDate, `${message}\n`, 'utf8',
err => {
if (err) {
this.emit('reject', `${message} has not been logged , reason: ${err.code}`);
}
else {
this.emit('success', `${message} has been load`);
}
});
}
this is my code. i suppose to check if message contains one of the “wordsIgnore” array words. how could i manage to make the “if statment” to check it … i added if statment but it still appending the disallowed words . thank you for help guys .!