The Udemy course for javascript provides an exercise, which is to write a simple program that quizzes the user. It is to create an alert in the browser, and then log the (randomly chosen) questions to the browser’s console. The answers all have an associated number, so the user only needs to enter the number. The console will state whether the question was correct or not, and the quiz will repeat, until the user enters “exit” into the prompt.
Its a very simple idea, but practice with a new language makes perfect, so I gave it a go.
I went a little further by adding a random function to the array class prototype, and also would not accept non-numeric answers. The main quiz function is an immediately invoked function expression (IIFE). Below is the code to this simple little program: