🎮ArcadeLab

Test

by StealthTiger71
36 lines1.3 KB
▶ Play
<!DOCTYPE html>
<html><head><meta charset="UTF-8"><title>Test</title>
<style>body{background:#0f172a;color:#fff;font-family:Arial;padding:20px}
.q{font-size:18px;margin:20px 0}.opt{padding:12px;margin:8px 0;background:#334155;border-radius:8px;cursor:pointer}
.opt.sel{background:#0ea5e9}button{padding:10px 20px;background:#22c55e;color:#fff;border:none;border-radius:6px;cursor:pointer;margin-top:10px}</style>
</head><body>
<div id="app"></div>
<script>
var Q=[
{q:"1+1=?",o:["1","2","3","4"],a:1},
{q:"2x3=?",o:["5","6","7","8"],a:1},
{q:"5-2=?",o:["2","3","4","5"],a:1},
{q:"10/2=?",o:["3","4","5","6"],a:2},
{q:"7+3=?",o:["8","9","10","11"],a:2}
];
var cur=0,ans=[null,null,null,null,null];
function render(){
var q=Q[cur];
var html='<div class="q">Q'+(cur+1)+'. '+q.q+'</div>';
for(var i=0;i<q.o.length;i++){
var sel=ans[cur]===i?' sel':'';
html+='<div class="opt'+sel+'" onclick="pick('+i+')">'+String.fromCharCode(65+i)+'. '+q.o[i]+'</div>';
}
html+='<button onclick="next()">Next</button>';
document.getElementById("app").innerHTML=html;
}
function pick(i){ans[cur]=i;render();}
function next(){
if(cur<Q.length-1){cur++;render();}
else{
var c=0;for(var i=0;i<Q.length;i++){if(ans[i]===Q[i].a)c++;}
document.getElementById("app").innerHTML='<h2>Score: '+c+'/5</h2><button onclick="location.reload()">Retry</button>';
}
}
render();
</script></body></html>

Game Source: Test

Creator: StealthTiger71

Libraries: none

Complexity: simple (36 lines, 1.3 KB)

The full source code is displayed above on this page.

Remix Instructions

To remix this game, copy the source code above and modify it. Add a ARCADELAB header at the top with "remix_of: test-stealthtiger71" to link back to the original. Then publish at arcadelab.ai/publish.