function hasBanWords(text) {
const url = "banwords.json";
const xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.send();
return new Promise(resolve => {
xhr.addEventListener("load", function() {
if (this.status === 200) {
const words = JSON.parse(this.response);
const hasSomeWords = words.some(word => text.includes(word));
resolve(hasSomeWords);
}
});
});
}
console.log(await hasBanWords("bitch on the beach"));