Building a Multiple Choice Quiz | Javascript | Tutorial 24

Поділитися
Вставка
  • Опубліковано 2 січ 2025

КОМЕНТАРІ • 114

  • @arewenot
    @arewenot 4 роки тому +76

    "What color is a strawberry?"
    Mike: red
    HTML: WRONG

  • @ellx_0
    @ellx_0 2 роки тому +3

    Mike you are really an amazing teacher, I watched a video thats 1 hour length and didnt get a single thing and in the end it was just full of mistakes but you just speak so clearly and explain everything in detail that I can understand and not just copy the code, you are so underrated btw, thank you for creating such high quality classes you are saving my life litereally.

  • @JassarDev
    @JassarDev 5 років тому +8

    Finished your python lessons and am almost done with these ones. Your explanation of concepts is very well organized. Thank you so much.

  • @porker5749
    @porker5749 5 років тому +28

    Thanks Mike. Could you show us how to do that using radio buttons rather than a text entry area?

  • @matthewsmith1571
    @matthewsmith1571 3 роки тому +13

    I actually managed to do this by myself before watching the tutorial. Seems like things are finally starting to click

  • @emonshah680
    @emonshah680 4 роки тому +4

    hey mike i have one question about this
    can you set up a timer with it for user to answer their question within that time

  • @balloney2175
    @balloney2175 Рік тому

    Well explained, straight to the point, and simple. Kudos!!!

  • @simbaevans.3301
    @simbaevans.3301 6 місяців тому +1

    Finished Tutorial 24.Thanks to Mike

  • @0119325
    @0119325 5 років тому +2

    How can I transform from a div in html with question to an array in js but showing it to the user?

  • @MalkiaMmoja
    @MalkiaMmoja Рік тому

    Thank you for your awesome tutorials.

  • @Dylann344
    @Dylann344 2 роки тому

    Nice Work Nathaniel B!!!

  • @OMEGA-bd6uf
    @OMEGA-bd6uf 2 роки тому

    All I gotta say is wow I mean damn never seen a tutorial so concise and straight to the point shit bro

  • @stefanjovanovic3382
    @stefanjovanovic3382 5 років тому +5

    Mike,you should update code on your site.I fixed it:
    var questions = [
    {
    prompt: "What color are apples?
    (a) Red/Green
    (b) Purple
    (c) Orange",
    answer: "a"// idk why did you use
    \Purple instead of
    Purple
    },
    {
    prompt: "What color are Bananas?
    (a) Teal
    (b) Magenta
    (c) Yellow",
    answer: "c"// you used
    \Magenta instead of
    Magenta
    },
    {
    prompt: "What color are strawberries?
    (a) Yellow
    (b) Red
    (c) Blue",
    answer: "b"//ans. is not a,you used
    \Red instead of
    Red
    }
    ];
    var score = 0;
    for(var i = 0; i < questions.length; i++){
    var response = window.prompt(questions[i].prompt);
    if(response == questions[i].answer){
    score++;
    alert("Correct!");
    } else {
    alert("WRONG!");
    }
    }
    alert("you got " + score + "/" + questions.length);

  • @robertoverbey3202
    @robertoverbey3202 6 років тому +3

    Hey Mike, I appreciate your videos. I watch you and Bob Tabor. I took your PHP course too. I have a request and a suggestion for you. For the request, I would really like to see you make a video that explains implementing a shopping cart and payment system in a website. Most of the videos I have seen regarding this are very specific to something like Wordpress (which I don't use). I would like to know more about the whole process of first choosing a payment processor and then actually tying it into a website with code. You have the skills to explain this in an understandable way. As a suggestion, if you would change to a lavalier microphone, the sound quality of your videos would be much better. Since you don't need to physically move a lot in your videos, you could even get by with a $20 corded version like the Boya by-m1 and it would make a big improvement over your shotgun mic. Anyway, thanks for the easy to understand and free knowledge. You've been a great help to me.

  • @christianlewis9359
    @christianlewis9359 5 років тому +1

    Great video thanks! Do you have another video of applying a timer to the quiz??

  • @blakehoward9432
    @blakehoward9432 2 роки тому

    How would I do this but instead of print boxes use radio buttons?

  • @ScreenPrintR
    @ScreenPrintR 2 роки тому

    Thanks Mike, after the questions are answered, and you get, you got 3/3 or whatever, I click ok, and the questions repeat. Been trying to include a Break code, but it's not working. You, or anyone have an answer or suggestion to stop the questions from repeating?

  • @xrayfisg
    @xrayfisg 10 місяців тому

    For some reason I can’t seem to actually read the question out to the user, it just shows up undefined or whatever and I can’t figure out what’s wrong.

  • @MsCellobass
    @MsCellobass 2 роки тому

    im a javascript beginner. That helps! Thank you!

  • @eid9552
    @eid9552 5 років тому +1

    Hi, thanks for the video. I have a question. If I have 1000 questions with 4 MCQs, how should i manage these data?

  • @mahmoudadel6965
    @mahmoudadel6965 5 років тому +2

    Can I make a timer for this quiz working during answering ?\

    • @neil224
      @neil224 4 роки тому +1

      ya I guess you can. You could set a variable equal to timer and decrease it every second, with a for/while loop. Then you could reset it or not, as you wish

  • @notashark8663
    @notashark8663 5 років тому +2

    Thanks, searched so much for a simple way to do this, and found you. Good job on the video

  • @arepaconqueso4800
    @arepaconqueso4800 2 роки тому +1

    Gives me this error>
    /Users/pao/Documents/Code/Charlie/test.js:36
    var response = window.prompt(questions[i].prompt);
    ^
    ReferenceError: window is not defined

  • @stevexavier2952
    @stevexavier2952 5 років тому

    What software do you use for your screencast?

  • @kolyxix
    @kolyxix 5 років тому

    Great job, this is right project explanation for a beginner in JavaScript. Exactly what I am looking for

  • @buckboot
    @buckboot 6 років тому

    Do you have to put things inside the variable questions?

  • @ESNexxer
    @ESNexxer 2 роки тому

    you solve my all problems like a Boss😂

  • @cuaresmapauliney.2701
    @cuaresmapauliney.2701 5 років тому +2

    Why can't i execute it on my browser?

    • @scottisitt
      @scottisitt 4 роки тому

      I would check for syntax or spelling errors. Especially, keep track of what goes on which side of the brackets. This is usually why I can't get JS to work on my browser. Also, check to make sure you've spelled the JS file name when you reference it in your html file.

  • @abdurrafaywali4756
    @abdurrafaywali4756 Рік тому

    Could anyone please tell me why he didn't put a semicolon at the end of the questions array, and the program still worked!?

  • @scottisitt
    @scottisitt 4 роки тому +1

    That's awesome! Thanks for this, Mike!

  • @fashozgames9295
    @fashozgames9295 3 роки тому

    if(response == questions[i].answer){//
    alert("you got " + score + "/" + questions.length);
    What is the interpretation of these codes?

  • @debill2043
    @debill2043 5 років тому

    how can randomize the questions and questions are not repeated...

  • @evony42209
    @evony42209 3 роки тому

    Hi,
    What if the question has multiple correct answers? Does that work?

  • @sirmacademy
    @sirmacademy 6 років тому

    Nice one. Can we add image to a question? How?

  • @mohamedanshaf1680
    @mohamedanshaf1680 4 роки тому

    i create html page with moving imge ok after how could i add ai.js file to the html same image's up ?
    its coming js file up moving imge down how to get same border with all file ?

  • @gaurigokakakar6887
    @gaurigokakakar6887 4 роки тому

    Awsome teaching 👏

  • @EmmanuelMusicians8
    @EmmanuelMusicians8 4 роки тому +1

    can you show the html code as well

    • @scottisitt
      @scottisitt 4 роки тому +1

      This is what I wrote as my html:

      JS Multiple Choice Quiz

      JavaScript Multiple Choice Quiz

      Important thing is to have your JS file referenced in the script tags.

  • @aliffnabil5542
    @aliffnabil5542 4 роки тому

    i could not really understand what window.promp(question[i].prompt) meant?
    can someone care to explain?

  • @krstev29
    @krstev29 Рік тому

    Hey everyone! Does someone know how can i make something similar, with only Html, Css and JavaScript, but you get different options every time

  • @skarbazalam4284
    @skarbazalam4284 2 роки тому

    how to set time for every random number addition

  • @brany2920
    @brany2920 Рік тому

    your work was well explained and perfect but you didnt show in most of your teachings you skipped the html and css. i do need to see how you added the table to i can follow along and get same result please.

  • @caladbol
    @caladbol 3 роки тому

    Man you're awesome, but I laughed so hard at the strawberries part.

  • @harshkapoor1678
    @harshkapoor1678 6 років тому +1

    My bro I cant thank you enough for this..

  • @ravanmaram
    @ravanmaram Рік тому

    hey its nice
    i have 3000 questions how to convert to array data

  • @MohamedSuleiman
    @MohamedSuleiman 5 років тому

    great tutorial and great job, well done. many thanks

  • @e.aldeen.a7492
    @e.aldeen.a7492 2 роки тому

    awsome 😍😍

  • @leonzlotnik4135
    @leonzlotnik4135 5 років тому +1

    awesome man!! nice going

  • @cyphodias1640
    @cyphodias1640 4 роки тому +2

    I threw another monkey wrench into the code. On your line 22 I entered a #1 instead of the letter ' i ' for (questions[ i ].prompt); and it kept asking me the Bananas question 3 times lol

  • @baajwajee5691
    @baajwajee5691 5 років тому

    You are just great....
    man great job .....very helpful.GOD BLESS yuh

  • @bluespider6537
    @bluespider6537 6 років тому +1

    Very helpful!! Thank you so much!

  • @farhanislam3707
    @farhanislam3707 6 років тому

    How we can comparison right and wrong answer at the end of quiZ??

  • @menayarinine2918
    @menayarinine2918 4 роки тому

    Thanks it was really nice and helpful

  • @sruthigopi7224
    @sruthigopi7224 6 років тому +1

    is this code is executed.did anyone check????

    • @scottisitt
      @scottisitt 4 роки тому +1

      I'm answering a year late, but, yes, it did work for me.

    • @Just_a_girl_in_a_new_city
      @Just_a_girl_in_a_new_city 4 роки тому +1

      @@scottisitt my code is not working, can u find the mistake.
      var questions= [
      {
      prompt:"what is your name?
      (a)deepa

      (b)rita
      (c)Gita",
      answer:" a"
      },
      {
      prompt:"what is your age?
      (a)10

      (b)17
      (c)18",
      answer: "c"
      },
      {
      prompt:"what is your scool?
      (a)univrsal

      (b)venky
      (c)kmc",
      answer: "a"
      },
      ];
      var score = 0;
      for(var i=0;i

    • @scottisitt
      @scottisitt 4 роки тому +1

      @@Just_a_girl_in_a_new_city Just a couple small errors. I put comments in your code, but I'll summarize first:
      1. In your second question, you had put options (b) and (c) on the next line, so they were not seen as part of the string anymore. The 17 and 18 were showing up as integers instead.
      2. Your alert("right!!") was on the same line as score++; ...So I moved that down to the next line.
      Here is the code fixed. You can try it out:
      var questions= [
      {
      prompt:"what is your name?
      (a)deepa
      (b)rita
      (c)Gita",
      answer:"a"
      },
      {
      prompt:"what is your age?
      (a)10
      (b)17
      (c)18", /*

    • @Just_a_girl_in_a_new_city
      @Just_a_girl_in_a_new_city 4 роки тому +1

      @@scottisitt much tnks for ur help, but it doesn't seems to work for me ,maybe because I m doing this all in my Android phone. But as u are saying the code worked for u so I think code is correct..so tnks.

    • @scottisitt
      @scottisitt 4 роки тому

      @@Just_a_girl_in_a_new_city ​ Hmm... What text editor or IDE are you using? I didn't know you could code on mobile devices, but I checked online and it looks like you can. One IDE I saw recommended was Dcoder (yes, spelled without the first "e"). Looks like it supports HTML and JavaScript....among many others. Maybe you can try using that...?
      I also checked to see if there were any formatting issues from copying and pasting the corrected code from the UA-cam comment section back to my editor...but there were no problems. The code still worked. So, yeah, maybe try Dcoder or something similar.

  • @charlotteaneriksson1577
    @charlotteaneriksson1577 6 років тому +1

    Hi ! Great video....

  • @saeducacion
    @saeducacion 6 років тому

    WHAT APPLICATION DO YOU USE TO MAKE AMAZING TUTORIAL??

    • @rollerskdude
      @rollerskdude 5 років тому

      VS code

    • @notrevvz
      @notrevvz 4 роки тому

      @@rollerskdude It's atom. look on the top left next to the apple logo (the menubar).

  • @davidbermudez7704
    @davidbermudez7704 4 роки тому

    Very good tutorial thank you useful for a project I’m working on

  • @schawnettarobinson8584
    @schawnettarobinson8584 4 роки тому

    Great video..

  • @nikolaidisandreas
    @nikolaidisandreas 4 роки тому

    Can someone explain what the
    means?!?

    • @Peter-sc1ru
      @Peter-sc1ru 4 роки тому

      its a regular expression. it starts a new line its like i think

  • @daviddon2606
    @daviddon2606 2 роки тому

    I need a personal help with this

  • @smmosfequrrahaman3768
    @smmosfequrrahaman3768 6 років тому

    this is another useful tutorial , thank you

  • @brinaural
    @brinaural 6 років тому

    you're a lifesaver. thank you!

  • @ytlagu2010
    @ytlagu2010 6 років тому

    Hey mike can you do a tutorial on applescript?

  • @cesarsanchez9701
    @cesarsanchez9701 3 роки тому

    Dear Mike,
    Thank you very much for taking the time to teach others. You do a wonderful job. Can you do me a favor, please? Can you show me the html code for this multiple choice code? I will appreciate it!
    Regards,
    Cesar

    • @ScreenPrintR
      @ScreenPrintR 2 роки тому

      I know it's been awhile. In html, since the JS is using alerts, you only need to add a link. I'd put it in the the head. Ask Away My Friend, Blah Blah BlaH

  • @dogethegamer551
    @dogethegamer551 3 роки тому

    I have discovered a "cleaner" and more basic way for this code.
    score = 0;
    function question(question, answer) {
    var reply = prompt(question)
    if(reply === answer) {
    alert('Correct!')
    score += 1
    } else {
    alert('WRONG!')
    }
    }
    question("question here", "answer here");
    alert("Your score: " + score);

    • @somebodyhere8620
      @somebodyhere8620 3 роки тому

      That's good, but it is not cleaner, because you dont't use arrays and you can't make count of right questions like 2/3.

  • @kyokazamaz2007
    @kyokazamaz2007 3 роки тому

    how to convert html to exe

  • @trevorsmith7763
    @trevorsmith7763 6 років тому

    what is the
    ?

  • @atulcodex7730
    @atulcodex7730 6 років тому

    hii, you know how to make quiz game with jquery.

  • @lifeafterindia6826
    @lifeafterindia6826 4 роки тому

    show me the html code of this part

  • @liamh-s9319
    @liamh-s9319 5 років тому +1

    Yes, strawberries are indeed yellow...

  • @niteshkrsah2222
    @niteshkrsah2222 4 роки тому

    it was really good tutorial

  • @ralfspinoza
    @ralfspinoza 6 років тому

    good work. thank you for that.

  • @superpantman
    @superpantman 2 роки тому

    window is not defined.

  • @yusufrazakhan2443
    @yusufrazakhan2443 2 роки тому

    osm video mike

  • @PepsiBlueDiedSlow
    @PepsiBlueDiedSlow 2 роки тому

    this isnt working for me

  • @prakashchaudhary839
    @prakashchaudhary839 7 років тому +1

    hey brother make a quiz which gives a rank to someone who attempt it among who have already attempted it

  • @markster3750
    @markster3750 2 роки тому

    THANKS MAN

  • @shermainerecto7730
    @shermainerecto7730 4 роки тому

    tnx

  • @abdallahlazhari2536
    @abdallahlazhari2536 3 роки тому

    Goood word i med the complett code plz and thank

  • @richardmaxuk
    @richardmaxuk 5 років тому

    you have .tort my how to code js

  • @Just_a_girl_in_a_new_city
    @Just_a_girl_in_a_new_city 4 роки тому

    var problems= [
    {
    prompt:"what is your name?
    (a)deepa

    (b)rita
    (c)Gita",
    answer:" a"
    },
    {
    prompt:"what is your age?
    (a)10

    (b)17
    (c)18",
    answer: "c"
    },
    {
    prompt:"what is your scool?
    (a)univrsal

    (b)venky
    (c)kmc",
    answer: "a"
    },
    ];
    var score = 0;
    for(var i=0;i

    • @sharp2448
      @sharp2448 4 роки тому

      you have "else{ "wrong!!!"}" should be "else{alert(wrong!!!)}"

    • @keithponcardasofficial
      @keithponcardasofficial 3 роки тому

      you variable score is not same as you initialize it what is 'marks' ?

  • @wazirabrar8790
    @wazirabrar8790 6 років тому

    great

  • @lucane8172
    @lucane8172 4 роки тому

    It's a bit confusing though

  • @rohitbhunya1896
    @rohitbhunya1896 4 роки тому

    helo Mike

  • @NoumanKhan-ck7vx
    @NoumanKhan-ck7vx 4 роки тому

    mike insta id please :)