JSFiddle - React, Tailwind, and code Playground

by jacobwsmith

JavaScript

var badwords = '|11352544|38977727|60554033|36688491|34026383|74915834|30720850|52821701|17445651|30002295|26615819|34161178|31846456|41266535|27998350|49204984|31641034|31254389|11517634|26307896|14053042|18041554|73724428|14411113|84623318|17933546|83210710|83359120|13575774|44913966|35606888|12076507|39523803|31384987|35740960|80268824|102662787|41985753|21208071|26220003|26875753|11672199|38894504|35705247|16218206|35687109|38522165|119094189|40237231|45165694|58762714|43228740|44629060|56199148|49986589|25962118|35157126|21928137|30871459|25318374|63437314|23510462|19694410|39450338|14367307|46014084|77395899|16914730|24113089|11643882|20454109|39856997|31278522|8766480|13488066|45273414|13757762|15089726|24766163|29832178|19823960|20585790|69357347|43099026|41722878|29080179|39330536|47177490|13913821|23509103|41874779|48063552|26449937|19116466|';

// encode a word to compare to list
function wordencode(word) {
	wen = 1000 + word.length;
	for (web=0;web<word.length;web++) {
        
        console.log(word.charCodeAt(web));
		wen = wen + (word.charCodeAt(web) * word.charCodeAt(web) * word.charCodeAt(web) * (web+1));
        //console.log(wen);
	}
    console.log(word + ' = ' + wen);
	return wen;	
}

//wordencode('is');
//is = 4200377
//wordencode(4200377)
function worddecode(wen){
    word = '';
    
}

// check if a word is in list of bad words
function iswordbad(suspiciousword) {
	if (badwords.indexOf('|' + wordencode(suspiciousword) + '|') != -1) {
		return true;
	} else {
		return false;
	}
}

function check_badwords(txt) {
	txt = txt.replace(/[^a-zA-Z ]/g,' ');
	allwords = txt.split(' ');
	foundwords = '';
	for (fc=0;fc<allwords.length;fc++) {
		if (iswordbad(allwords[fc])) {
			if (foundwords != '') {
				comma = ', ';
			} else {
				comma = '';
			}
			foundwords = foundwords + comma + allwords[fc];
		}
	}
	
	if (foundwords != '') {
		alert('Don\'t say ' + foundwords + ' because those words are bad')
    }
}

check_badwords('this is an example...