当我eval(command)
在控制台中尝试时,它只会给我“未定义”。我想要做的是将“命令”作为一行。如何?
str = ""
command = ""
if (document.checks.cb1.checked) {str += " && randomNum3 != 1"}
if (document.checks.cb2.checked) {str += " && randomNum3 != 2"}
if (document.checks.cb3.checked) {str += " && randomNum3 != 3"}
if (document.checks.cb4.checked) {str += " && randomNum3 != 4"}
command = "while (str == str" + str + ") {randomNum3 = Math.floor(Math.random() * (1 - 5)) + 5}"
eval(command)