Answer:
Using javascript, explanation with javascript comment
Explanation:
function guessNumber(){
var randomize= math.random()*10;
var roundrand= math.floor(randomize);
var getInput= prompt("guess number from 1 to 10");
var x= 3;
do(
if(getInput>roundrand){
Console.log("your guess is too high");
guessNumber();
}
if(getInput<roundrand){
Console.log("your guess is too high");
guessNumber();
}
else{
Console.log("you are correct pal!");
break;
}
)
while(x<=3)
}
/*Observe that we have used a recursive function that calls the function guessNumber again inside the function definition if the input fails the if condition and doesn't guess correctly. It checks for a correct number 3 times with the do... while loop and breaks out of the function once the user enters a correct input.*/