Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form name="myForm">
- <div id='myForm'></div>
- </form>
- function partC(){
- var guessCount = 10;
- var random = Math.round(Math.random()*100);
- var button = document.createElement('input');
- button.type = "button";
- button.value = " Guess! ";
- document.getElementById('myForm').appendChild(button);
- var textbox = document.createElement('input');
- textbox.type = 'number';
- document.getElementById('myForm').appendChild(textbox);
- var check = document.getElementById('textbox').value
- button.onclick = calc(guessCount, random, check);
- }
- function calc(guessCount, random, check){
- while(guessCount > 0) {
- if (check == random){
- alert("Correct!");
- } else if (check > random) {
- alert("Try Again. Guess to High. " + guessCount + " tries left.");
- } else if (check < random) {
- alert("Try Again. Guess to Low. " + guessCount + " tries left.");
- }
- guessCount--;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement