Hi I am new to javascript, can you guys help me with the code . Here is the question
Write Javascript code that does the following :
A) Generates a random number in the range of 1 to 6 then store it within a variable.
B) The program should prompt the user to enter a number from in the range of 1 to 6.q
C) If the number entered by the user does not match the number generated in point A
display a message inside the browser to encourage the user try one more time.
Otherwise congratulate the user.
PS: Below is an example on how to prompt the user for input
Var name = prompt(“Please enter your name”);
Here is my code below:
<html>
<head>
<title>Brief 2 _Question 3 </title>
<body>
<script>
var generate1 = Math.floor(Math.random() * 7);
var ask_user = prompt("Enter the number between 1-6");
while(ask_user){
if (generate1 != ask_user){
var message = alert("Try one more time");
}else
message = alert("Congratulations");
}
</script>
</body>
</head>
</html>