Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Dec 2013
    Thanked 0 Times in 0 Posts

    Smile just need a little help, on a code

    So, the problem I'm having is that I want to make a code, but i don't where to start. The code is going to randomly pick 2 questions, that are provided, and when you answer both right you move on. So for example I would write 50 questions and the answer for them, and then when you start the code up, it will asks you 2 of the 50 questions and when you get the 2 questions, right you'll move on. So if anyone could help me out, by explaining in the comments or by put a link to a video explaining it, anything would be appreciated. Thanks

  2. #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    London, England
    Thanked 2,699 Times in 2,675 Posts
    One more time, this forum is not a free coding service. As a general rule, the people helping out in this forum don't write code for others, but try to help with fixing code that doesn't work. You may perhaps get someone to write this script for you, but you'll be far more likely to get help if you have made a substantial effort and written some code yourself. Then someone here will almost certainly help you correct/improve your work.

    So you are quite entitled to "a little help", but not to have someone do your homework for you.

    What resources have you tried so far?

    Be aware that all Javascript quizzes have the serious defect that the user can see the correct answer simply by using "View Source".

    Rather than pick questions at random (which means that the same question may appear twice), you will need to shuffle the questions into random order and then take the first two, the next two and so on. This means that the answers must be in the same array index as the question, and separated out by splitting at the delimiter. Example:-

    var myQuestions = [];
    myQuestions[0] = "Who wrote Romeo and Juliet?~~Shakespeare";
    myQuestions[1] = "Who is the President of the USA?"~~Obama";
    myQuestions[2] = "How many beans make 5?~~5";
    // and so on.

    The array will need to be shuffled into random order, or it would be simpler to just present the questions in sequential order. Get that right first, then add the refinement of shuffling.

    For the purposes of the comparison the user's answer and the correct answer will need to be converted to lower case. Javascript is case sensitive so obama != Obama.

    You will also need to keep a count of the number of correct answers.

    Use the search facility of this forum for guidance.

    But I have the idea that this assignment is too difficult for you at this stage in your programming development. You are trying to run before you can walk. You say that you are 8th grade - which I understand is age 12-14.

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.
    Last edited by Philip M; 01-09-2014 at 09:15 AM. Reason: typo

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts