私も作成した変数から特定の単語を削除するために使用される関数を作成しました。
var eliminateWord = function (usedwords){word2.replace (/go/g," ");
しかし、私はこのコードで関数を使用していないようです:
var word1 = "go",
word2 = "go to the shops everyday and buy chocolate.";
var eliminateWord = function (usedwords){
word2.replace (/go/g," ");
};
if (word2.match("go")) {
console.log("user entered go");
eliminateWord ();
}
if (word2.match("to")) {
console.log("user entered to");
}
if (word2.match("the")) {
console.log("user entered the");
}
if (word2.match("and")) {
console.log("user entered and");
}
console.log(word2);