number input Box 1, Box 2, and a button. Box 2 randomly generates a random number variable between 1 and 2 equal to the amount entered into Box 2 where 1= Success and 2= fail. Box 1 is the amount of times Box 2 has to randomly generate only the number 1. If the number 2 is randomly generated at any time, the message "Failed" appears on a banner and Success if every randomly generated number is the number 1. There is a button that loops the function until a success appears.
var randomNumber = Math.floor(Math.random() * 2) + 1; var times = document.querySelector("#amount").value; var counter = 0; function Success() { if (randomNumber = 1 && counter < times) { counter++; return "success"; } else if (randomNumber = 2) return "fail"; }