Problem is that, prompt has to be a part of while. The while is operating on the first userInput only and you are not updating it. This seems to work:
<!DOCTYPE html>
<meta charset="utf-8">
<style>
</style>
<body>
<script id="mainScript" type="text/javascript">
!function(){
var loopTerminate = false,
res = undefined,
oddEven = undefined,
count = 0,
rgxAnswer = /^yes$/i,
rgxIsNumber = /^(?:[1-9][0-9]+)$|^[0-9]$/;
function loop(){
res = prompt("Wanna test "+(!count ? "a" : "another")+" number?");
count++;
if(rgxAnswer.test(res)){
testNumber();
} else {
loopTerminate = true;
}
};
function testNumber(){
res = prompt("Enter a number");
if(!rgxIsNumber.test(res)){
alert("Not a number!");
} else {
oddEven = +res % 2 === 0;
alert("Number is "+ (oddEven ? "even" : "odd"));
}
};
while(!loopTerminate){loop()};
}();
</script>
</body>
</html>
Save it as html and open it.