Jsfiddle
basically the structure is
1. An array declared with all the questions and answers.
2. A function to ask all the questions and update the score.
3. Loop to loop through the array .
all very clean and simple to understand .
now heres the problem , now i want ask the user what level of difficulty he wants the questions to be . so say for example i have two levels of difficulty easy and hard .
so in the beginning now instead of one array there are 2 arrays :
-
- var questionseasy = [['Whats is 2 + 2' , '4'] , ['What is 3 * 3' , '9'] , ['What is 5 * 5' , '25']];
-
- var questionshard = [['Whats my name' , 'Ian'] , ['Where am i from' , 'India'] , ['My favorite Food' , 'Idly']];
I wrote a few lines of JS code but was still not able to figure out .
how to successfully select the arrays (either one) depending on what the user chooses his difficulty level to be . i did succeed in writing a function that checks whats the users difficulty level preference .
so far my progress has been this
Js fiddle
Basically in my quest to build a simple JS quiz that has the ability to ask a user whats his preference of Questions (Easy , hard etc) is and than display the questions based on what his preferences are has seen half success , can somebody come along and explain the simple logic or where i am going wrong ?
so far here is what i have done . will really appreciate any help .
Thank you .
Gautam .