JSFiddle - React, Tailwind, and code Playground
by 규연 황
JavaScript
var questionList = [
{
question: '오늘의 요일은?',
answer: '수요일',
score: 20,
subtract: 1
},
{
question: '미국의 수도는 어디입니까?',
answer: '워싱턴',
score: 40,
subtract: 4
},
{
question: '물에 가라앉고 있는 나라는?',
answer: '몰디브',
score: 70,
subtract: 5
}
];
var score = 0;
var minus = 0;
var total = 0;
questionList.forEach(function test(currentQuestion){
var answer = prompt(currentQuestion.question);
total = total + currentQuestion.score;
if (answer == currentQuestion.answer) {
score = score + currentQuestion.score;
} else {
score = score - currentQuestion.subtract;
}
});
//alert(total);
if (score == total) {
alert('당신의 점수는 ' + score + '점 만점 입니다');
} else {
alert('당신의 점수는 총' + total + '점 중에 ' + score + '점 입니다');
}