Guest User

Untitled

a guest
Feb 17th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Guessing Game Demo</title>
  5. </head>
  6. <body >
  7. <h1>My First Program</h1>
  8. <script>
  9. var arrayQuestions = [
  10. "Hey Who is your Favourite Director?",
  11. "None other than ",
  12. "Which movie do you like most of placeholder?",
  13. "Good. So you like movie .... ",
  14. "How many times did you watch placeholder movie?",
  15. "Great. So you watched ",
  16. "Did you ever Meet your Favourite Director - Y or N ",
  17. ];
  18. var arrayAnswers = [];
  19. var i;
  20. for (i=0; i < arrayQuestions.length; i+=2) {
  21. if (i === 0) {
  22. arrayAnswers[i] = prompt(arrayQuestions[0]);
  23. if (arrayAnswers[i] == "") {
  24. alert ("Please enter your favourite director, to proceed for next questionary !");
  25. break;
  26. }
  27. }
  28. else if (i <= 6) {
  29. arrayAnswers[i] = prompt(arrayQuestions[i-1] + arrayAnswers[i-2] + '...' + arrayQuestions[i].replace("placeholder", arrayAnswers[i-2]));
  30. if (arrayAnswers[i] == "") {
  31. alert ("Please provide your input, to complete the remaining questionary !");
  32. break;
  33. }
  34. }
  35. else {
  36. arrayAnswers[i] = prompt(arrayQuestions[i-1] + arrayAnswers[i-2]);
  37. }
  38. console.log(arrayQuestions[i] + ':' + arrayAnswers[i]);
  39. }
  40. if (arrayAnswers[i] != "" ) {
  41. alert ('Thanks Venu.'
  42. + '! Great to know that you like ' + arrayAnswers[0]
  43. + ' and the love for director'
  44. + ".");
  45. if (arrayAnswers[6].toUpperCase() === 'Y' || arrayAnswers[6].toUpperCase() === 'YES') {
  46. alert ("Have a good day !");}
  47. else {
  48. alert ("Better Luck next time !");
  49. }
  50. }
  51. </script>
  52. </body>
  53. </html>
Add Comment
Please, Sign In to add comment