我是编程新手。我学习了一点JavaScript,并制作了一段代码。当所有事情都是真实的时候,这一切都很好,但是当它是错误的时候,我需要添加一些事情来发生。所以我添加了一个while
,它并没有为我工作。有人可以帮助我吗?谢谢你的答案!不知道这个代码有什么问题
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<link rel="stylesheet" href="styles.css"/>
<script src="JavaScript.js"></script>
<title>
Hello
</title>
</head>
<body>
<p id="Hello"></p>
<script>
function onload() {
alert("choose a number between 1 and 9");
var Multiply1 = prompt("Multiply this number by 9");
while (Multiply1 % 9 != 0) {
alert("This can't be true");
var Multiply = prompt("Multiply this number by 9");
}
while (multiply1 % 9 = 0) {
var add = prompt("Add the 2 digits you have");
}
while (add != 9) {
alert("This can't be true");
var add1 = prompt("Add the 2 digits you have");
}
while (add = 9) {
var decrease = prompt("deacrease the number you have chosen from the number you got:");
alert("the number you have chosen is " + (9-decrease));
}
}
</script>
<noscript>Please enable JS</noscript>
<button onclick="onload()">Cilck on me to start"</button>
</body>
</html>
欢迎堆栈溢出。请阅读http://stackoverflow.com/help/how-to-ask,它将帮助您如何提问。就目前而言,这个问题属于“为什么不用这个代码?”这个类别,它将被删除。我们希望您能够努力解决问题,而不只是向我们展示代码并询问为什么它不起作用。 – Mikkel