Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const axios = require('axios')
- const randomArray = (arr) => {
- return arr[Math.floor(Math.random() * arr.length)]
- }
- const questions = async () => {
- const res = await axios.get('https://json.nxr.my.id/c/hXBPY')
- return res.data
- }
- var Set = {
- started: true,
- attempt: 0,
- hint: randomArray(['A', 'B', 'C', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']),
- ans: '',
- question: []
- }
- const flow = setInterval(async () => {
- Set.attempt += 1
- if (Set.started) {
- Set.started = false
- const json = await (await questions()).find(v => v.jawaban.startsWith(Set.hint))
- Set.ans = json.jawaban
- Set.question.push(json)
- console.log(`Question : ${Set.attempt}. ${json.pertanyaan} (${json.jawaban})`)
- } else {
- const ans = Set.ans.split`` [Set.ans.split``.length - 1]
- const json = await (await questions()).find(v => v.jawaban.startsWith(ans))
- Set.ans = json.jawaban
- Set.question.push(json)
- console.log(`Question : ${Set.attempt}. ${json.pertanyaan} (${json.jawaban})`)
- }
- if (Set.attempt >= 10) {
- clearInterval(flow)
- console.log(Set.question)
- }
- }, 3000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement