Question: This question relates to Javascript. What is the simplest way to modify the code below so that it keeps asking for the user to enter
This question relates to Javascript.
What is the simplest way to modify the code below so that it keeps asking for the user to enter the correct value if the user enters an incorrect response. At the moment the code willaccept empty that the user enters nothing. Please show me how to fix this. Please keep it simple because I am new to coding.
const VALID_TEAMS = ["Australia","New Zealand","South-Africa","Pakistan","Brazil","West Indies"]; const MIN = 0; const MAX = 30; const TEAM_NUM = 6; var score = 0; var findTeam; var team; var i; document.writeln(""); for(i=0;i<=TEAM_NUM;i++){ team = prompt("enter the team"); findTeam = VALID_TEAMS.indexOf(team); if(findTeam>=0 && findTeam<=5){ document.writeln(""); document.writeln(""); score = prompt("enter the score"); while(isNaN(score) || score<0 || score>30 || score %3 !=0){ score = prompt("enter the score"); } document.writeln(""); } document.writeln(""); } document.writeln("
| "+team+" | "+score+" |
");
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
