I have one question. I am making some quiz and I need your help. We need to display random questions with no repeat. I don't know how to make that. I'm a beginner in JavaScript. Under is my code.
 import { State } from "../../../framework/StateBase";
import { Conversation } from "../../../framework/ConversationBase";
import { getLanguage } from "../../../gateways/GigaaaGateway";
import { RatherGameGateway } from "../gateway/RatherGameGateway";
export class GetUserQuestionState extends State {
    constructor(conversation: Conversation, name: string) {
        super(conversation, name);
    }
    public configure(convo: any, bot: any) {
        convo.beforeThread(this.name, async convo => {
            let gateway = new RatherGameGateway();
            let age = this.conversation.payload.userAges;
            let ageCategory: number;
            try {
                let lang = await getLanguage(this.conversation.languageId, bot);
                if (age > 11) {
                    ageCategory = 0;
                    let result = await gateway.findLangCodeAndAge(lang.code, ageCategory);
                    if (this.conversation.payload.counter === 0) {
                        this.conversation.payload.params.question = result[0].questions[Math.floor(Math.random())];
                    } else if (this.conversation.payload.counter > 0) {
                        this.conversation.payload.params.next_question = result[0].questions[this.conversation.payload.counter];
                    }
                    this.conversation.payload.counter++;
                } else if (age >= 4 && age <= 11) {
                    ageCategory = 1;
                    let result = await gateway.findLangCodeAndAge(lang.code, ageCategory);
                    if (this.conversation.payload.counter === 0) {
                        this.conversation.payload.params.question = result[0].questions[0];
                    } else if (this.conversation.payload.counter > 0) {
                        this.conversation.payload.params.next_question = result[0].questions[this.conversation.payload.counter];
                    }
                    this.conversation.payload.counter++;
                }
            } catch (error) {
                this.conversation.payload.error = true;
            }
            convo.gotoThread(this.conversation.getNextState());
        });
    }
}
Just look if loop. Thank you very much!
 
     
    