npm i aniquiz
const animequiz = require('aniquiz')
// Random quiz object
console.log(animequiz.getEntry())
// Quiz object with difficulty
console.log(animequiz.getEntry({ difficulty: 'easy' }))
// Quiz object with image
console.log(animequiz.getEntry({ image: true })
// Quiz object without image
console.log(animequiz.getEntry({ image: false }))
property | type | default |
---|---|---|
difficulty | string | none |
image | boolean | none |
Property | type | description |
---|---|---|
difficulty | string | The difficulty of the question |
time | number | The time in ms the question should be answered |
question | string | The question |
answers | array | The array of possible answers |
image | string | The image of the question, if applicable |
submittedBy | string | The one created the question |
id | string | The id of this question |
custom | boolean | Whether this quiz object was manually added |
Success
{
difficulty: 'Hard',
time: 20000,
question: 'The name of Junko Enoshima’s imposter at the beginning of Danganronpa: Trigger Happy Havoc is?',
answers: [ 'mukuro ikusaba', 'ikusaba mukuro' ],
image: null,
submittedBy: 'Sakurajimai',
id: '111'
}
Error
{ error: 'error msg.' }
Creating a quiz instance allows you to prevent receiving the same question twice
const { Quiz } = require('aniquiz');
// class parameters accepts options
const quiz = new Quiz({ difficulty: 'easy' })
// Quiz object
console.log(quiz.getEntry())
// Quiz entries
console.log(quiz.getEntries())
// Accepts options parameter as well
If instance runs out of quiz entry, you encounter the following error
{ error: 'Exhausted entries.' }
You can reload entries by using
quiz.reload(options)
or add your own entries via
quiz.addEntries([])
Added entries will be appended with custom property which is set to true.