function fn(name) {
var jc = ["敏感字符", "广电总局"];
var gc = ["*****", "****"];
if(typeof(name) === "string") {
for(var j = 0; j < jc.length; j++) {
for(var i = 0; i < name.length; i++) {
name = name.replace(jc[j], gc[j]);
};
};
console.log(name);
} else {
if(name instanceof Array) {
for(var k = 0; k < name.length; k++) {
if(typeof(name[k]) === "string") {
var ar=name[k].split("");
if(name[k].charCodeAt(i) < 255){
ar[0]=name[k][0].toUpperCase()
name[k]=ar.join("")
}else{
ar[0]=name[k][0].bold()
name[k]=ar.join("")
};
}
};
console.log(name);
document.write(name);
}else{
console.log("超出检测范围")
return "超出检测范围"
}
}
};
var str = '如果传入字符串,检测字符串的敏感词("敏感字符","广电总局"),如果传入字符串,检测字符串的敏感词("敏感字符","广电总局"),如果传入字符串,检测字符串的敏感词("敏感字符","广电总局"),如果传入字符串,检测字符串的敏感词("敏感字符","广电总局"),'
fn(str);
var arr = [2, 44, "敏感字符", 33, "cheng", 546, "广电总局", "yang"];
fn(arr);
fn(3);