Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Guessing Game Demo</title>
- </head>
- <body >
- <h1>My First Program</h1>
- <script>
- var arrayQuestions = [
- "Hey Who is your Favourite Director?",
- "None other than ",
- "Which movie do you like most of placeholder?",
- "Good. So you like movie .... ",
- "How many times did you watch placeholder movie?",
- "Great. So you watched ",
- "Did you ever Meet your Favourite Director - Y or N ",
- ];
- var arrayAnswers = [];
- var i;
- for (i=0; i < arrayQuestions.length; i+=2) {
- if (i === 0) {
- arrayAnswers[i] = prompt(arrayQuestions[0]);
- if (arrayAnswers[i] == "") {
- alert ("Please enter your favourite director, to proceed for next questionary !");
- break;
- }
- }
- else if (i <= 6) {
- arrayAnswers[i] = prompt(arrayQuestions[i-1] + arrayAnswers[i-2] + '...' + arrayQuestions[i].replace("placeholder", arrayAnswers[i-2]));
- if (arrayAnswers[i] == "") {
- alert ("Please provide your input, to complete the remaining questionary !");
- break;
- }
- }
- else {
- arrayAnswers[i] = prompt(arrayQuestions[i-1] + arrayAnswers[i-2]);
- }
- console.log(arrayQuestions[i] + ':' + arrayAnswers[i]);
- }
- if (arrayAnswers[i] != "" ) {
- alert ('Thanks Venu.'
- + '! Great to know that you like ' + arrayAnswers[0]
- + ' and the love for director'
- + ".");
- if (arrayAnswers[6].toUpperCase() === 'Y' || arrayAnswers[6].toUpperCase() === 'YES') {
- alert ("Have a good day !");}
- else {
- alert ("Better Luck next time !");
- }
- }
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment