GithubHelp home page GithubHelp logo

bhavyavadavalli / cli-quiz Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 1.0 12 KB

This is a CLI quiz app on "How well do you know me?"

Home Page: https://replit.com/@bhavyaVadavalli/CLI-QUIZ#index.jsembed=1&&output=1

License: MIT License

JavaScript 100.00%

cli-quiz's Introduction

  • ๐Ÿ‘‹ Hi, Iโ€™m Bhavya .
  • ๐Ÿ‘€ Iโ€™m interested in designing and Developing
  • ๐ŸŒฑ Iโ€™m currently learning Frontend skills

An image of @bhavyavadavalli's Holopin badges

cli-quiz's People

Contributors

bhavyavadavalli avatar lalitharamanav avatar

Watchers

 avatar

Forkers

lalitharamanav

cli-quiz's Issues

fix: fix in index

var readlineSync = require("readline-sync");
const chalk = require('chalk');
const error = chalk.bold.red;
const correct = chalk.bold.green;
const bgGreen = chalk.black.bgGreen;

var highscore = {
name: "Lalitha",
topScore: 8
};
var score = 0;

quizList = [
{
question: "Is My Age Greater Than 15? \n",
answer: "No"
},
{
question: "Am I Introvert or Extovert?\n ",
answer: "Extrovert"
},
{
question: "Where do I live? \n",
answer: "Vizag"
},
{
question: "What is my favorite icecream flavour? \n",
answer: "Chocolate"
},
{
question: "What is my favourite food? \n",
answer: "Biryani"
},
{
question: "Who is my favourite Teacher? \n",
answer: "Tanay Pratap"
},
{
question: "Do I prefer coffee or tea? \n ",
answer: "Coffee"
},
{
question : "Guess when is my birthday month? \n",
answer: "March"
},
{
question: "What is my favourite colour? \n",
answer: "Black"
},
{
question: "What is my hobby? \n",
answer: "Reading Books"
}
]

function welcomeMessage(){
console.log(bgGreen("Bhavya's Quiz"));
console.log("A quiz to check how well do you know me? ")

console.log("\n");

var userName = readlineSync.question("Hello! Who's this? Please enter your name! \n" );

console.log( (("Welcome to")+ chalk.cyan(" How well do you know Bhavya's quiz ") + chalk.bgGreen(userName ) ));

console.log("Let's play! ");
readlineSync.question( chalk.cyan("Can you beat this HIGHSCORE " + highscore.topScore +" ? Press enter to play! \n") );
playGame();
}

function checkAnswer(n,question, answer){
var userAnswer = readlineSync.question(n + "." + (question));

if(userAnswer.toLowerCase() === answer.toLowerCase()){
console.log(correct("You are right! "));
score++;
console.log("Current Score: "+ chalk.green(score));

}
else{
console.log(error("You are wrong! "));
console.log("Current Score: " + chalk.red(score) );
}
console.log("\n");
}

function playGame(){
for(var i=0; i<quizList.length; i++){
checkAnswer(i+1, quizList[i].question, quizList[i].answer);
}
displayScore();
}

function displayScore(){
console.log((chalk.cyan("Hurray! Your total score is " + chalk.green(score))));

if(score > highscore.topScore){
highscore.topScore = score;
console.log("Congratulations! You have beaten the highscore");
console.log("New HIGHSCORE: "+ highscore);
}
console.log(chalk.cyan("Thanks for playing.") );
console.log(bgGreen("Don't forget to share screenshot."));
}

welcomeMessage();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.