how to make a bad word filter in javascript

Solutions on MaxInterview for how to make a bad word filter in javascript by the best coders in the world

showing results for - "how to make a bad word filter in javascript"
Philippine
21 Jan 2020
1/*
2    This code comes from Vincent Lab
3    And it has a video version linked here: https://www.youtube.com/watch?v=spBRgujJ3xw
4*/
5
6// Import dependencies
7const Filter = require("bad-words");
8
9// Make a new filter
10const filter = new Filter();
11
12// https://www.cs.cmu.edu/~biglou/resources/
13// Add extra words to the bad words list
14const words = require("./extra-words.json");
15filter.addWords(...words);
16
17// Test the bad words filter
18console.log(filter.clean("Don't be an ash0le"));
19console.log(filter.clean("You fucking mother fucker"));
20console.log(filter.clean("You are a son of a whore"));
21console.log(filter.clean("You fucking fucknut"));
22console.log(filter.clean("fucking cunt"));
23console.log(filter.clean("You are a shit ass"));
24console.log(filter.clean("This fucking product is unbelievable"));
25console.log(filter.clean("You are a bitch"));