Skip to content

Commit 9327a44

Browse files
authored
badword.js
1 parent 5c9dbc4 commit 9327a44

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

badword.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
11
// Periksa lingkungan eksekusi
22
const isNode = typeof exports === 'object' && typeof module !== 'undefined';
3-
43
/**
54
* Fungsi untuk memeriksa apakah kata cocok dengan pola regex
65
* @param {string} word - string kata yang akan diperiksa
76
* @param {regex} regex - pola regex yang akan digunakan untuk memeriksa kata-kata
87
* @return {boolean} - true jika kata cocok dengan pola regex, false jika tidak
98
*/
109
function RegexMatch(word, regex) {
11-
const words = word.trim();
10+
var words = word.trim();
1211
let barisdata = [];
1312
if (words){
1413
for (let index = 0; index < words.length; index++) {
1514
let datacocok = barisdata.join("").toLowerCase();
1615
if (datacocok.match(regex)){
1716
return true;
1817
}else{
18+
if (words[index].indexOf("3")){
19+
words = words.replace("3","e");
20+
}else if(words[index].indexOf("0")){
21+
words = words.replace("0","o");
22+
}else if(words[index].indexOf("4")){
23+
words = words.replace("4","a");
24+
}else if(words[index].indexOf("5")){
25+
words = words.replace("5","s");
26+
}else if(words[index].indexOf("8")){
27+
words = words.replace("8","b");
28+
};
29+
1930
if (datacocok.replace(/1/gi, "i").match(regex)){
2031
return true;
2132
}else if (datacocok.replace(/1/gi, "l").match(regex)){
@@ -26,17 +37,7 @@ function RegexMatch(word, regex) {
2637
return true;
2738
};
2839

29-
if (words[index].indexOf("3")){
30-
words[index] = "e";
31-
}else if(words[index].indexOf("0")){
32-
words[index] = "o";
33-
}else if(words[index].indexOf("4")){
34-
words[index] = "a";
35-
}else if(words[index].indexOf("5")){
36-
words[index] = "s";
37-
}else if(words[index].indexOf("8")){
38-
words[index] = "b";
39-
};
40+
4041
};
4142
barisdata.push(words[index].trim());
4243
};
@@ -505,7 +506,6 @@ const exportsObject = {
505506

506507
// Ekspor ke lingkungan yang sesuai
507508
//isNode ? module.exports = exportsObject : Object.assign(window, exportsObject);
508-
// Ekspor ke lingkungan yang sesuai
509509
if (isNode) {
510510
// Jika di Node.js, gunakan module.exports
511511
module.exports = exportsObject;

0 commit comments

Comments
 (0)