Skip to content

Instantly share code, notes, and snippets.

@lpj145
Last active May 22, 2021 12:58
Show Gist options
  • Save lpj145/b0fb1b495db8c9f95aa74071019bff83 to your computer and use it in GitHub Desktop.
Save lpj145/b0fb1b495db8c9f95aa74071019bff83 to your computer and use it in GitHub Desktop.
const questions = [
'WHats your name ?',
'The book is on the table ?',
'The car is moving ?',
'Is the best or worst driver you see ?'
]
let currentQuestion = 0
const showQuestion = () => {
console.log(questions[currentQuestion])
}
const nextQuestion = () => {
if (questions.length > 0 && currentQuestion < questions.length)
{
currentQuestion += 1
}
showQuestion()
}
const prevQuestion = () => {
if (questions.length > 0 && currentQuestion > 0)
{
currentQuestion -= 1
}
showQuestion()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment