Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let points = 0;
- let wantsToExit = false;
- while (wantsToExit === false) {
- let question = prompt("Player 1: Enter a question. Type 'exit' to end the game");
- if(question ==="exit"){
- alert("Game over");
- wantsToExit=true;
- }
- else if(question !=="exit"){
- let right_answer = prompt("Player 2: " + question + " Type 'exit' to end the game");
- if(right_answer === "exit"){
- alert("Game over");
- wantsToExit=true
- }
- else if(right_answer !=="exit"){
- let answer = prompt("Player 2: " + question + " Type 'exit' to end the game");
- if(answer==="exit"){
- alert("Game over");
- wantsToExit=true;
- }
- else if (answer === right_answer) {
- alert("Woo hoo, you've got a point");
- points = points + 1;
- } else {
- alert("Wrong answer, try again");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement