Writting a program using javascript and inquirerJS to ask question and play game, if dont want to play ok end game, if want to play more( ask for guessed number and show computer generated number greet if correct else better luck next time)
I tried solving and solved much but have technical problems related program logic and inquirerJS, Just run this code in your editor and you will know the error its logical and i dont know how to solve it.
`
import inquirer from 'inquirer';
const question =[
{
type : 'input' ,
name : 'first_question' ,
message : ' Are you ready to play this number guessing game ? \n If yes(Y) otherwise No(N) '
},
{
type: 'list',
name: 'input',
message : "So what's your guessed number ? ",
choices: ['1','2','3','4','5','6','7','8','9','10']
}
]
console.log("-------------------------------");
inquirer
.prompt(question)
.then((answers) => {
const question1 = answers.first_question ;
const choices = answers.input;
// const question2 = answers.second_question ;
let x = 0;
x = getRandomInt();
function getRandomInt() {
return Math.floor(Math.random() * 10);
}
if(question1=== 'Y' || question1==='y'){
console.log(`You choose this ${choices}`)
if(choices == x){
console.log(`Great yor answer is ${x} and its correct `)
}else{
console.log(`Your guessed ${choices} and computer generated number is ${x} \nBetter luck next time ` )
}
}else if(question1==='N'|| question1 === 'n'){
console.log("If you don't want to play OK")
}
})
`