我想为某些单词制作内容过滤器,然后取出单词并在控制台日志中显示它们。 这是js Fiddle链接: http://jsfiddle.net/Kz42U/4/
var words1 = prompt("Type In Anything");
var words2 = prompt("Type In Anything");
if (words1 == words2){
alert("Words are Equal");
}
else {
alert("Words Are Not Equal");
}
var eliminateWord = function (doubles) {
if "go" in words1():{
console.log("user has entered go")
}
};
答案 0 :(得分:0)
使用.match
"foo bar mania".match("foo"); // ["foo"]
和
var word1 = "go",
word2 = "go kart";
var entered = word1.match("word2");
if (entered) {
console.log("words match");
} else {
console.log("words don't match"); // output
}
if (word2.match("go")) {
console.log("user entered go"); // output
}