dimanche 6 octobre 2019

Turning static questions into dynamic questions

I have static questions such as below. I'm using these questions for my quiz in my blog.

var quiz = {
    "data": [
        {
            "question": "What is 10 + 5 ?",
            "answer": "15",
        },
        {
            "question": "What is 10 - 5 ?",
            "answer": "5",
        },
        {
            "question": "What is 10 + (- 5) ?",
            "answer": "5",
        },
        {
            "question": "What is -10 + 5 ?",
            "answer": "-5",
        },
        {
            "question": "What is -6 + (-6) ?",
            "answer": "-12",
        },
    ]
}

How can i make the questions & answer dynamic? In other words, each of the numbers will take a value between 1 and 20. The answer will be calculated based on the question.

thanks




Aucun commentaire:

Enregistrer un commentaire