Previous QuestionNext QuestionSubmit Quiz
//Question1
//Define Variables
var one1, one2, one3, one4, one5
//Assigns Random Integers
one1 = Math.floor(Math.random()*11)+1;
one2 = Math.floor(Math.random()*11)+1;
one3 = Math.floor(Math.random()*11)+1;
one4 = Math.floor(Math.random()*11)+1;
one5 = Math.floor(Math.random()*11)+1;
//find mean
onemean = (one1+one2+one3+one4+one5)/5;
onem1 = (one1+one2+one3+one4+one5)/4;
onem2 = (one1*one2*one3*one4*one5)/125;
onem3 = (one1+one2+one3+one4+one5)/2;
//Answer Choices
onecorrectanswer = onemean.toFixed(3).replace(/\.?0+$/,"").toString();
oneanswer1 = onem1.toFixed(3).replace(/\.?0+$/,"").toString();
oneanswer2 = onem2.toFixed(3).replace(/\.?0+$/,"").toString();
oneanswer3 = onem3.toFixed(3).replace(/\.?0+$/,"").toString();
//Place Answer Choices into Array
oneanswerchoices = [oneanswer1, oneanswer2, oneanswer3, onecorrectanswer];
//Randomize Answer Choices
do {
var indexa = Math.floor(Math.random()*oneanswerchoices.length);
var indexb = Math.floor(Math.random()*oneanswerchoices.length);
}
while (indexb == indexa);
do {
var indexc = Math.floor(Math.random()*oneanswerchoices.length);
}
while (indexc == indexa || indexc == indexb);
do {
var indexd = Math.floor(Math.random()*oneanswerchoices.length);
}
while (indexd == indexa || indexd == indexb ||
indexd == indexc);
onea = oneanswerchoices[indexa];
oneb = oneanswerchoices[indexb];
onec = oneanswerchoices[indexc];
oned = oneanswerchoices[indexd];
if (indexa == 3) {
onecorrectchoice = "a"
}
if (indexb == 3) {
onecorrectchoice = "b"
}
if (indexc == 3) {
onecorrectchoice = "c"
}
if (indexd == 3) {
onecorrectchoice = "d"
}
//Qeustion 1 Question
question1 = "1. Find the Mean of the following Data set: " + one1.toString() + ", " + one2.toString() + ", " + one3.toString() + ", " + one4.toString() + ", " + one5.toString();
//Question2
//Define Variables
var two1, two2, two3, two4, two5
//Assigns Random Integers
two1 = Math.floor(Math.random()*11)+1;
two2 = Math.floor(Math.random()*11)+1;
two3 = Math.floor(Math.random()*11)+1;
two4 = Math.floor(Math.random()*11)+1;
two5 = Math.floor(Math.random()*11)+1;
//find standard deviation
twomean = (two1+two2+two3+two4+two5)/5;
twosd = Math.sqrt((Math.pow(two1-twomean,2)+Math.pow(two2-twomean,2)+Math.pow(two3-twomean,2)+Math.pow(two5-twomean,2)+Math.pow(two5-twomean,2))/4);
twosd1 = Math.sqrt((Math.pow(two1,2)+Math.pow(two2,2)+Math.pow(two3,2)+Math.pow(two5,2)+Math.pow(two5,2))/5);
twosd2 = Math.sqrt(Math.abs((Math.pow(two1-twomean,1)+Math.pow(two2-twomean,1)+Math.pow(two3-twomean,1)+Math.pow(two5-twomean,1)+Math.pow(two5-twomean,1)))/5);
twosd3 = Math.sqrt((Math.pow(two1-twomean,2)+Math.pow(two2-twomean,2)+Math.pow(two3-twomean,2)+Math.pow(two5-twomean,2)+Math.pow(two5-twomean,2))/5);
//Answer Choices
twocorrectanswer = twosd.toFixed(3).replace(/\.?0+$/,"").toString();
twoanswer1 = twosd1.toFixed(3).replace(/\.?0+$/,"").toString();
twoanswer2 = twosd2.toFixed(3).replace(/\.?0+$/,"").toString();
twoanswer3 = twosd3.toFixed(3).replace(/\.?0+$/,"").toString();
//Place Answer Choices into Array
twoanswerchoices = [twoanswer1, twoanswer2, twoanswer3, twocorrectanswer];
//Randomize Answer Choices
do {
var indexa = Math.floor(Math.random()*twoanswerchoices.length);
var indexb = Math.floor(Math.random()*twoanswerchoices.length);
}
while (indexb == indexa);
do {
var indexc = Math.floor(Math.random()*twoanswerchoices.length);
}
while (indexc == indexa || indexc == indexb);
do {
var indexd = Math.floor(Math.random()*twoanswerchoices.length);
}
while (indexd == indexa || indexd == indexb ||
indexd == indexc);
twoa = twoanswerchoices[indexa];
twob = twoanswerchoices[indexb];
twoc = twoanswerchoices[indexc];
twod = twoanswerchoices[indexd];
if (indexa == 3) {
twocorrectchoice = "a"
}
if (indexb == 3) {
twocorrectchoice = "b"
}
if (indexc == 3) {
twocorrectchoice = "c"
}
if (indexd == 3) {
twocorrectchoice = "d"
}
//Question 2 Question
question2 = "2. Find the Standard Deviation of the following Data set: " + two1.toString() + ", " + two2.toString() + ", " + two3.toString() + ", " + two4.toString() + ", " + two5.toString();
//Question3
//define variables
var three1, threep
//Assign Random Integers
three1 = Math.floor(Math.random()*7)+2;
//find probability
if (three1 == 2) {
threep = 1/6;
}
else if (three1 == 3) {
threep = 2/6;
}
else if (three1 == 4) {
threep = 3/6;
}
else if (three1 == 5) {
threep = 4/6;
}
else {
threep = 5/6;
}
//Answer Choices
threecorrectanswer = threep.toFixed(3).replace(/\.?0+$/,"").toString();
threeanswer1 = (threep+(1/6)).toFixed(3).replace(/\.?0+$/,"").toString();
threeanswer2 = (threep-(1/6)).toFixed(3).replace(/\.?0+$/,"").toString();
threeanswer3 = (threep+0.5).toFixed(3).replace(/\.?0+$/,"").toString();
//Place Answer Choices into Array
threeanswerchoices = [threeanswer1, threeanswer2, threeanswer3, threecorrectanswer];
//Randomize Answer Choices
do {
var indexa = Math.floor(Math.random()*threeanswerchoices.length);
var indexb = Math.floor(Math.random()*threeanswerchoices.length);
}
while (indexb == indexa);
do {
var indexc = Math.floor(Math.random()*threeanswerchoices.length);
}
while (indexc == indexa || indexc == indexb);
do {
var indexd = Math.floor(Math.random()*threeanswerchoices.length);
}
while (indexd == indexa || indexd == indexb ||
indexd == indexc);
threea = threeanswerchoices[indexa];
threeb = threeanswerchoices[indexb];
threec = threeanswerchoices[indexc];
threed = threeanswerchoices[indexd];
if (indexa == 3) {
threecorrectchoice = "a"
}
if (indexb == 3) {
threecorrectchoice = "b"
}
if (indexc == 3) {
threecorrectchoice = "c"
}
if (indexd == 3) {
threecorrectchoice = "d"
}
//Question 3 Question
question3 = "3. When rolling a six-sided dice what is the probability of rolling a number less than " + three1.toString();
//Qestion4
//define variables
var four1, four2
//Assign Random Integers
do {
four1 = Math.floor(Math.random()*11)+2;
four2 = Math.floor(Math.random()*6)+2;
}
while (four1 >= four2);
//find combinations
four2fact = 1;
for (i = 1; i <= four2; i++) {
four2fact = four2fact*i
};
four1fact = 1;
for (i = 1; i <= four1; i++) {
four1fact = four1fact*i
};
four21fact = 1;
for (i = 1; i <= four2-four1; i++) {
four21fact = four21fact*i
};
fourc = four2fact/(four1fact*four21fact);
//Answer Choices
fourcorrectanswer = fourc.toString();
fouranswer1 = (Math.ceil(four2*four1)).toString();
fouranswer2 = (Math.ceil(four2fact)).toString();
fouranswer3 = (Math.ceil(four1fact)).toString();
//Place Answer Choices into Array
fouranswerchoices = [fouranswer1, fouranswer2, fouranswer3, fourcorrectanswer];
//Randomize Answer Choices
do {
var indexa = Math.floor(Math.random()*fouranswerchoices.length);
var indexb = Math.floor(Math.random()*fouranswerchoices.length);
}
while (indexb == indexa);
do {
var indexc = Math.floor(Math.random()*fouranswerchoices.length);
}
while (indexc == indexa || indexc == indexb);
do {
var indexd = Math.floor(Math.random()*fouranswerchoices.length);
}
while (indexd == indexa || indexd == indexb ||
indexd == indexc);
foura = fouranswerchoices[indexa];
fourb = fouranswerchoices[indexb];
fourc = fouranswerchoices[indexc];
fourd = fouranswerchoices[indexd];
if (indexa == 3) {
fourcorrectchoice = "a"
}
if (indexb == 3) {
fourcorrectchoice = "b"
}
if (indexc == 3) {
fourcorrectchoice = "c"
}
if (indexd == 3) {
fourcorrectchoice = "d"
}
//Qeustion 4 Question
question4 = "4. You are in charge of assigning " + four1.toString() + " of your coworkers to the party planning committee. " + four2.toString() + " of your coworkers are eligible to be part of this committee. How many different combinations of party planning commitees could you create?"
//Question5
//define variables
var five1, five2
//Get Random Integers
do {
five1 = Math.floor(Math.random()*11)+2;
five2 = Math.floor(Math.random()*11)+2;
}
while (five1 <= five2);
//find perm
five1fact = 1;
for (i = 1; i <= five1; i++) {
five1fact = five1fact*i
};
five12fact = 1;
for (i = 1; i <= five1-five2; i++) {
five12fact = five12fact*i
};
five2fact = 1;
for (i = 1; i <= five2; i++) {
five2fact = five2fact*i
};
five21fact = 1;
for (i = 1; i <= five2-five1; i++) {
five21fact = five21fact*i
};
fivep = five1fact/five12fact;
//Answer Choices
fivecorrectanswer = fivep.toString();
fiveanswer1 = (five1fact/five21fact).toString();
fiveanswer2 = (Math.ceil(five2fact/five2)).toString();
fiveanswer3 = (Math.ceil(five1fact/five2fact)).toString();
//Place Answers into Array
fiveanswerchoices = [fiveanswer1, fiveanswer2,fiveanswer3, fivecorrectanswer];
//Randomize Answer Choices
do {
var indexa = Math.floor(Math.random()*fiveanswerchoices.length);
var indexb = Math.floor(Math.random()*fiveanswerchoices.length);
}
while (indexb == indexa);
do {
var indexc = Math.floor(Math.random()*fiveanswerchoices.length);
}
while (indexc == indexa || indexc == indexb);
do {
var indexd = Math.floor(Math.random()*fiveanswerchoices.length);
}
while (indexd == indexa || indexd == indexb ||
indexd == indexc);
fivea = fiveanswerchoices[indexa];
fiveb = fiveanswerchoices[indexb];
fivec = fiveanswerchoices[indexc];
fived = fiveanswerchoices[indexd];
if (indexa == 3) {
fivecorrectchoice = "a"
}
if (indexb == 3) {
fivecorrectchoice = "b"
}
if (indexc == 3) {
fivecorrectchoice = "c"
}
if (indexd == 3) {
fivecorrectchoice = "d"
}
//Question 5 Question
question5 = "5. You are arranging cookies on plates. There are " + five1.toString() + " different types of cookies and you can place " + five2.toString() + " cookies on each plate. If each place has to have different types of cookies on it, how many different cookie arrangements can you make?"
//Question6
//define variables
var sixred, sixblue, sixgreen
//Assign Random Variables
do {
sixred = Math.floor(Math.random()*6)+1;
sixblue = Math.floor(Math.random()*6)+1;
sixgreen = Math.floor(Math.random()*6)+1;
}
while (sixred == sixgreen || sixred == sixblue || sixgreen == sixblue);
//Find p
sixn = sixred+sixblue+sixgreen;
sixnfact = 1;
for (i = 1; i <= sixn; i++) {
sixnfact = sixnfact*i
};
sixredfact = 1;
for (i = 1; i <= sixred; i++) {
sixredfact = sixredfact*i
};
sixbluefact = 1;
for (i = 1; i <= sixblue; i++) {
sixbluefact = sixbluefact*i
};
sixgreenfact = 1;
for (i = 1; i <= sixgreen; i++) {
sixgreenfact = sixgreenfact*i
};
sixp = sixnfact/(sixredfact*sixbluefact*sixgreenfact);
//Answer Choices
sixcorrectanswer = sixp.toString();
sixanswer1 = (sixnfact/(sixredfact*sixgreenfact)).toString();
sixanswer2 = (Math.ceil((sixnfact*sixredfact)/(sixred*sixblue*sixgreen))).toString();
sixanswer3 = (Math.ceil(sixnfact)/(sixblue*sixgreen*sixred)).toString();
//Place answers into Array
sixanswerchoices = [sixanswer1, sixanswer2, sixanswer3, sixcorrectanswer];
//Randomize Answer Choices
do {
var indexa = Math.floor(Math.random()*sixanswerchoices.length);
var indexb = Math.floor(Math.random()*sixanswerchoices.length);
}
while (indexb == indexa);
do {
var indexc = Math.floor(Math.random()*sixanswerchoices.length);
}
while (indexc == indexa || indexc == indexb);
do {
var indexd = Math.floor(Math.random()*sixanswerchoices.length);
}
while (indexd == indexa || indexd == indexb ||
indexd == indexc);
sixa = sixanswerchoices[indexa];
sixb = sixanswerchoices[indexb];
sixc = sixanswerchoices[indexc];
sixd = sixanswerchoices[indexd];
if (indexa == 3) {
sixcorrectchoice = "a"
}
if (indexb == 3) {
sixcorrectchoice = "b"
}
if (indexc == 3) {
sixcorrectchoice = "c"
}
if (indexd == 3) {
sixcorrectchoice = "d"
}
//Question 6 Question
question6 = "6. You have " + sixn.toString() + " colored tiles. You have " + sixred.toString() + " red tiles, " + sixblue.toString() + " blue tiles, " + sixgreen.toString() + " green tiles. How many unique ways can the tiles be arranged?"
//Question7
//define variables
var sevenred, sevenblue, sevenyellow
//Assign Random Values
sevenred = Math.floor(Math.random()*11)+1;
sevenblue = Math.floor(Math.random()*11)+1;
sevenyellow = Math.floor(Math.random()*11)+1;
//find p
sevenn = sevenred+sevenblue+sevenyellow;
seven1 = sevenred/sevenn;
seven2 = sevenyellow/(sevenn-1);
sevenp = seven1*seven2;
sevenp1 = seven1*(sevenyellow/sevenn);
sevenp2 = seven1+seven2;
sevenp3 = Math.abs(seven1-seven2);
//AnswerChoices
sevencorrectanswer = sevenp.toFixed(3).replace(/\.?0+$/,"").toString();
sevenanswer1 = sevenp1.toFixed(3).replace(/\.?0+$/,"").toString();
sevenanswer2 = sevenp2.toFixed(3).replace(/\.?0+$/,"").toString();
sevenanswer3 = sevenp3.toFixed(3).replace(/\.?0+$/,"").toString();
//Place answers into Array
sevenanswerchoices = [sevenanswer1, sevenanswer2, sevenanswer3, sevencorrectanswer];
//Randomize Answer Choices
do {
var indexa = Math.floor(Math.random()*sevenanswerchoices.length);
var indexb = Math.floor(Math.random()*sevenanswerchoices.length);
}
while (indexb == indexa);
do {
var indexc = Math.floor(Math.random()*sevenanswerchoices.length);
}
while (indexc == indexa || indexc == indexb);
do {
var indexd = Math.floor(Math.random()*sevenanswerchoices.length);
}
while (indexd == indexa || indexd == indexb ||
indexd == indexc);
sevena = sevenanswerchoices[indexa];
sevenb = sevenanswerchoices[indexb];
sevenc = sevenanswerchoices[indexc];
sevend = sevenanswerchoices[indexd];
if (indexa == 3) {
sevencorrectchoice = "a"
}
if (indexb == 3) {
sevencorrectchoice = "b"
}
if (indexc == 3) {
sevencorrectchoice = "c"
}
if (indexd == 3) {
sevencorrectchoice = "d"
}
//Question 7 Question
question7 = "7. You have " + sevenn.toString() + " colored marbles in a bag. There are " + sevenred.toString() + " red marbles, " + sevenblue.toString() + " blue marbles, and " + sevenyellow.toString() + " yellow marbles. What is the probability of picking a red marble first, then a yellow marble?"
//Question Slides
const myQuestions = [
{
question: question1,
answers: {
a: onea,
b: oneb,
c: onec,
d: oned
},
correctAnswer: onecorrectchoice
},
{
question: question2,
answers: {
a: twoa,
b: twob,
c: twoc,
d: twod
},
correctAnswer: twocorrectchoice
},
{
question: question3,
answers: {
a: threea,
b: threeb,
c: threec,
d: threed
},
correctAnswer: threecorrectchoice
},
{
question: question4,
answers: {
a: foura,
b: fourb,
c: fourc,
d: fourd
},
correctAnswer: fourcorrectchoice
},
{
question: question5,
answers: {
a: fivea,
b: fiveb,
c: fivec,
d: fived
},
correctAnswer: fivecorrectchoice
},
{
question: question6,
answers: {
a: sixa,
b: sixb,
c: sixc,
d: sixd
},
correctAnswer: sixcorrectchoice
},
{
question: question7,
answers: {
a: sevena,
b: sevenb,
c: sevenc,
d: sevend
},
correctAnswer: sevencorrectchoice
}
];
function buildQuiz() {
// we'll need a place to store the HTML output
const output = [];
// for each question...
myQuestions.forEach((currentQuestion, questionNumber) => {
// we'll want to store the list of answer choices
const answers = [];
// and for each available answer...
for (letter in currentQuestion.answers) {
// ...add an HTML radio button
answers.push(
``
);
}
// add this question and its answers to the output
output.push(
`
${currentQuestion.question}
${answers.join("")}
`
);
});
// finally combine our output list into one string of HTML and put it on the page
quizContainer.innerHTML = output.join("");
}
function showResults() {
// gather answer containers from our quiz
const answerContainers = quizContainer.querySelectorAll(".answers");
// keep track of user's answers
let numCorrect = 0;
// for each question...
myQuestions.forEach((currentQuestion, questionNumber) => {
// find selected answer
const answerContainer = answerContainers[questionNumber];
const selector = `input[name=question${questionNumber}]:checked`;
const userAnswer = (answerContainer.querySelector(selector) || {}).value;
// if answer is correct
if (userAnswer === currentQuestion.correctAnswer) {
// add to the number of correct answers
numCorrect++;
// color the answers green
answerContainers[questionNumber].style.color = "green";
} else {
// if answer is wrong or blank
// color the answers red
answerContainers[questionNumber].style.color = "red";
}
});
// show number of correct answers out of total
resultsContainer.innerHTML = `${numCorrect} out of ${myQuestions.length}`;
}
function showSlide(n) {
slides[currentSlide].classList.remove("active-slide");
slides[n].classList.add("active-slide");
currentSlide = n;
if (currentSlide === 0) {
previousButton.style.display = "none";
} else {
previousButton.style.display = "inline-block";
}
if (currentSlide === slides.length - 1) {
nextButton.style.display = "none";
submitButton.style.display = "inline-block";
} else {
nextButton.style.display = "inline-block";
submitButton.style.display = "inline-block";
}
}
function showNextSlide() {
showSlide(currentSlide + 1);
}
function showPreviousSlide() {
showSlide(currentSlide - 1);
}
const quizContainer = document.getElementById("quiz");
const resultsContainer = document.getElementById("results");
const submitButton = document.getElementById("submit");
// display quiz right away
buildQuiz();
const previousButton = document.getElementById("previous");
const nextButton = document.getElementById("next");
const slides = document.querySelectorAll(".slide");
let currentSlide = 0;
showSlide(0);
// on submit, show results
submitButton.addEventListener("click", showResults);
previousButton.addEventListener("click", showPreviousSlide);
nextButton.addEventListener("click", showNextSlide);
Advertisements
error: Content is protected !!
Cookie Consent
We use cookies to improve your experience on our site. By using our site, you consent to cookies.
Registers a unique ID on mobile devices to enable tracking based on geographical GPS location.
1 day
VISITOR_INFO1_LIVE
Tries to estimate the users' bandwidth on pages with integrated YouTube videos. Also used for marketing
179 days
PREF
This cookie stores your preferences and other information, in particular preferred language, how many search results you wish to be shown on your page, and whether or not you wish to have Google’s SafeSearch filter turned on.
10 years from set/ update
YSC
Registers a unique ID to keep statistics of what videos from YouTube the user has seen.
Session
DEVICE_INFO
Used to detect if the visitor has accepted the marketing category in the cookie banner. This cookie is necessary for GDPR-compliance of the website.
179 days
LOGIN_INFO
This cookie is used to play YouTube videos embedded on the website.