JavaScript : Creating a Random Quiz
Dr Benton
Fundamentals
The aim of this quiz is to have your visitors guess the name of a computer which is only partly shown in a photograph. Our
example only uses three questions, so it wouldn't take a visitor long to check out the right answers. But this will suffice
for our purpose at this stage.
It's a good idea to start off with a base of fifteen questions. We will keep the smart Alecs on their toes by pulling out
three questions at random for each visit.
To set up this random draw, we will use the JavaScript function
math.random(). It returns a floating number between 0 and 1. We can combine it with a multiplication and the function
math.round() to obtain a procedure which can produce any integer number at random within a specific limit.
Back to the source. To follow this workshop, check out the
numbered version of our quiz source code.