Use JavaScript to Display Random Trivia on Click

preview_player
Показать описание
Create an array of random trivia facts and use a JavaScript function to display a different fact each time a user clicks a button.
Рекомендации по теме
Комментарии
Автор

How would you do this with audio files randomly played on click of that button? None of the tutorials or forums I've visited have helped me make this work yet!

pattyorigami
Автор

Thank you so much! Ive been trying to make a program like this forever and all the other sources i looked up made their code way more complex.

Mrdorsett
Автор

Can you please comment the css code of that website

jocelynprecioso
Автор

Breast fed babies score slightly higher on mental development tests than ones on formula.

SynxS
Автор

Anyone know how after you show a random array to push or slice it into another array so it doesn't pop up twice? I can't seem to figure it out.

GmoneyMozart
Автор

I used your tutorial as the logic for craps program. My question is: Am I on the right track for adding the sum of two random numbers pulled from two different arrays?

//button event will generate 2 random numbers and add them together

var num1 = [1, 2, 3, 4, 5, 6];
var num2 = [1, 2, 3, 4, 5, 6];
//var sum1 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
var sum2 = num1 + num2

function rollDice(){
var randomNumber = + num2));
= randomNumber[rollDice];
}

liquidsolomon
Автор

Thanks a million it is very good and easy. But I have a question, I want to have multiple choice questions in my array and I need to use j query instead of "getElementById", what should I do? If you help me with this I will thankful million times. It`s kinda urgent dear Ralph.

MahtabD
Автор

Cannot make it work, google says "Uncaught SyntaxError: Unexpected token } index2.html:16" witch is something to do when i call function (onclick) or the JS itself... i have literally copied the text on the video...
EDIT: deleted half bottom of HTML page and redid it in notepad, for some reason there where some ?"invisible characters"? messing the code....

StevenBotelho
Автор

I have some web page layouts. How much will you charge to help me launch my website?

emanc
Автор

i need html for this where i put the var starting ?

ElmoGoesPunk
Автор

Thanks for this awesome explanation. your are the best!

jennyinternetcafee
Автор

error: cannot read property "length" of undefined any help???

Flyspark
Автор

hey, you are awesome. great explanation.

girmaayele