I am new to HTML and have used Eclipse for Java before. Below I try to have the user enter a number (0-5), and try the computer and guess it.
I looked through it and it seems that it sounds, the only thing I have never done is to put an element equal to another element at the end of the loop.
Also the first time using non-instructions ( is it !== or !=?) in HTML/JavaScript.
HTML
<p>How many fingers am I holding up?</p>
<input id="fingers"></input>
<div>
<button id="button">Input fingers</button>
</div>
Javascript
var i = 0;
var cg = 0;
document.getElementById("button").onclick = function() {
while (i !== fingers) {
cg = Math.random();
cg = cg * 6;
cg = Math.floor(cg);
if (document.getElementById("cg").value !== fingers) {
alert("Wrong we found " + cg);
i = cg;
} else {
alert("The number of fingers is " + cg);
i = cg;
}
}
}
I myself study this for future use, I hope you can help! Thank.
source
share