previous

page 13

next

Simply change the first two lines in globals.js and you should have a new quiz!

Now I'd like to reduce those two lines to one so we don't have to type (eg) Movies twice!

We already 'know' the name from the first line so we can build the second line thus:

'var g_pics=g_'+g_dir

But how do we get JavaScript to evaluate the resulting string? With a new function, eval

So the second line of globals.js becomes:

eval('var g_pics=g_'+g_dir);

And now it's about time I implemented the score and restricted the number of questions as proposed on page 6!

Or are you too busy creating your third quiz?!?

previous
next