<!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>Skills 2</title>
</head>
<body>
<h1>Test your skills</h1>
<button>turn on the machine</button>
<section></section>
<script>
let score = 75;
let response = '';
let machineactive = false;
let section = document.querySelector('section');
let button = document.querySelector('button');
button.addEventListener('click', ()=>{
score = parseInt(Math.random()*100);
machineactive = true;
getDone();
section.innerHTML = '';
let para1 = document.createElement('p');
let para2 = document.createElement('p');
para1.textContent = score;
para2.textContent = response;
section.appendChild(para1);
section.appendChild(para2);
})
function getDone()
{ if (machineactive) {
if(score < 0 || score > 100) {
response = 'This is not possible, an error has occured.';
}else if(score >=0 && score <=19){
response = 'That was a terrible score - total fail!';
}else if(score <= 39){
response = 'You know some thing, but it\'s a pretty bad score. Needs improvement.';
} else if (score <= 69) {
response = 'you did a passsable job, not bad!'
} else if (score <= 89) {
response = 'What amazing score! Did you cheat? Are you for real?';
}
else {
response = 'You got a very high score'
}
}else {
response = 'The machine is turn off, turn it on';
}}
getDone();
</script>
</body>
</html>
Rute Bezerra de Menezes Gondim
No comments:
Post a Comment