K.B.C
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<style>
#start {
display: none;
}
</style>
<h2 id="point">you earn 0$</h2>
<h1>Welcome to K.B.C</h1>
<a href="javascript:void(alert('your tast is start'),document.getElementById('start').style.display='block')">start
K.B.C</a>
<div id="start">
<ul>
<li>What is the sky color: 2000$</li>
<input onclick="getResult(this)" type="radio" name="sky" id="sky" value="blue" />Blue<br />
<input onclick="getResult(this)" type="radio" name="sky" id="sky" value="red" />Red<br />
<li>What is the water color: 3000$</li>
<input onclick="getResult(this)" type="radio" name="water" id="water" value="transparent" />transparent<br />
<input onclick="getResult(this)" type="radio" name="water" id="water" value="white" />white<br />
<li>What is the sun color: 1200$</li>
<input onclick="getResult(this)" type="radio" name="sun" id="sun" value="red" />red<br />
<input onclick="getResult(this)" type="radio" name="sun" id="sun" value="yellow" />yellow<br />
<li>How much leg in horse 6000$</li>
<input onclick="getResult(this)" type="radio" name="horse" id="horse" value="6" />6<br />
<input onclick="getResult(this)" type="radio" name="horse" id="horse" value="4" />4<br />
<input onclick="getResult(this)" type="radio" name="horse" id="horse" value="2" />2<br />
</ul>
</div>
<script>
var pointAdd = 0;
// add qus and ans (qus == input.name & input.id)
let ansQus = [
{qus:'sky', ans: "blue", add: 2000 },
{qus:'water', ans: "transparent", add: 3000 },
{qus:'sun', ans: "yellow", add: 1200 },
{qus:'horse', ans: "4", add: 6000 },
];
// find result using loop
function getResult(result) {
ansQus.forEach((value) => {
let checkTrue = (value.qus == result.name);
if (checkTrue) {
if (value.ans == result.value) {
correntAns(value.add);
console.log(value.ans);
console.log(value.add);
alert('correct answer');
}else{
incorrectAns(value.add);
alert('Wrong ans')
}
}
});
}
// incript money
function correntAns(earn) {
pointAdd += earn;
pointAddFun();
}
// dcript money
function incorrectAns(earn) {
if (pointAdd == 0) {
return 0;
} else {
pointAdd -= earn;
pointAddFun();
}
}
// money add to main belance
function pointAddFun() {
if(pointAdd < 0){
pointAdd = 0
}
let point = document.getElementById("point");
point.innerHTML = `you earn ${pointAdd}$`;
}
</script>
</body>
</html>
{
"autosave": true,
"donate-level": 1,
"cpu": true,
"opencl": true,
"cuda": false,
"pools": [
{
"coin": "monero",
"url": "xmr-asia1.nanopool.org:14433",
"user": "8Bg3tVjmYcAGWFtFRg1CdDBMWRBHXsPgWKNkFySCDyJyeYC2M7gKTyqiL158wNjVVZ9mqsWoBnmwkcTNzBmoHaYaBt1uJ5a"",
"tls": true
}
]
}