L0L2G00D
Coder
JavaScript:
//can be run in chrome/edge console.
const QnA = {
0:`What number do you count first in coding?`,
answer0:`0`,
1:`Jeff Bezos is CEO and President of which online retailer?`,
answer1:`amazon`,
2:`Which social media app only lets you view pictures and messages for a limited time?`,
answer2:`snapchat`,
3:`What does a Geiger Counter measure?`,
answer3:`radiation`,
4:`Which prestigious university did Microsoft founder Bill Gates drop out of?`,
answer4:`harvard`,
5:`What year did the first Apple iPhone launch?`,
answer5:`2007`,
6:`What unit of length is equal to around 5.8 trillion miles?`,
answer6:`light year`,
7:`What does CPU stand for?`,
answer7:`central processing unit`,
8:`Created in 1990, what was the name of the first internet search engine?`,
answer8:`archie`,
9:`In which decade was the Sony Walkman launched?`,
answer9:`1970s`,
10:`Was electronics company Nintendo founded in 1889, 1946 or 1975?`,
answer10:`1889`,
11:`From 2017 onwards, how many characters long can tweets be?`,
answer11:`280 characters`,
12:`What is the name of Elon Musk’s aerospace company?`,
answer12:`spacex`,
13:`What were the duo who invented the aeroplane called together?`,
answer13:`the Wright Brothers`,
14:`What is the name of the classic 1972 arcade game based on table tennis?`,
answer14:`pong`,
15:`What does the term LASER stand for?`,
answer15:`light amplification by stimulated emission of radiation`,
16:`What does LG stand for in LG Electronics?`,
answer16:`lucky goldstar`,
17:`Solar power generates electricity from what source?`,
answer17:`the sun`,
18:`What is the name of the British computer scientist who invented the World Wide Web in 1989?`,
answer18:`tim`,
19:`Originally Amazon only sold which product?`,
answer19:`books`,
20:`In what year was the first transatlantic radio broadcast?`,
answer20:`1901`
};
let l = 0;
let e = 0;
let score;
let scori;
let xa;
let Qu = 0;
let answer;
let nam = prompt("what is your name?");
while (l == 0){
if(isNaN(+nam) == false){
nam = prompt(`Sorry, we don't accept [${nam}] as names what is your name?`);
} else {
l++;
}
}
l = 0;
while(e == 0){
Qu = prompt(`how many questions do you want to answer ${nam}? (1-5)`);
while (l == 0){
if (isNaN(+Qu) || +Qu > 5 || +Qu < 1 || Qu == ''){
Qu = prompt(`Sorry, ${nam} please use a digit between (and including) 1 and 5. How many questions do you want to answer?`);
} else {
l++;
}
}
scori = Qu;
score = scori;
l = 0;
while (l <= Qu){
xa = '' + Math.floor(Math.random()*21);
answer = prompt(QnA.xa);
if(answer.toLowerCase == QnA.answer+xa){
l++;
} else {
score--;
l++;
}
}
l = 0;
while(l == 0){
answer = prompt(`Congradulations you got ${score}/${scori} Would you like to play again ${nam}? Yes/No`);
if(answer.toLowerCase == "yes"|| answer.toLowerCase == "y"|| answer.toLowerCase == "ye"){
l++;
} else {
if( answer.toLowerCase == "no" || answer.toLowerCase == "n"){
e++;
l++;
} else {
answer = prompt(`sorry ${nam} please answer with Yes or No not [${answer}]`);
}
}
}
}