I`m having an assignment where I have to make a simple quiz, each right question must add 1 points to the score, here is my code
let app = new Vue({
el: '#app',
data: {
crameworks: [
{skor: 0}
],
frameworks: [
{ name: 'A.Charles Bababage',
votes : true },
{ name: 'B.Naruto',
votes : false },
{ name: 'C.Sasuke',
votes : false },
{ name: 'D.Belva',
votes : false},
],
grameworks : [
{ jawaban: 'A.Pochinok',
votes : true },
{ jawaban: 'B.Miramar',
votes : false },
{ jawaban: 'C.Tambang',
votes : false },
{ jawaban: 'D.Kampong',
votes : false}
],
vrameworks : [
{ answer: 'A.Bisa',
votes : false},
{ answer: 'B.Tidak',
votes : true},
{ answer: 'C.Mungkin',
votes : false},
{ answer: 'D.isin ku aa crown',
votes : false}
]
},
methods:{
skor(){
if(this.votes == true){
this.crameworks[0].skor + 1
}
}
}
})
here is my html file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>My App</title>
<script src="https://cdn.jsdelivr.net/npm/vue">
</script>
</head>
<body>
<div id="app">
<ul>
1.Pembuat Printer adalah
<br>
<p v-for="f in frameworks">
<input type="radio">
{{f.name}}
</p>
</ul>
<ul>
2.Berikut area dalam game PUBG, Kecuali
<br>
<p v-for="g in grameworks">
<input type="radio">
{{g.jawaban}}
</p>
</ul>
<ul>
3.Bisakah Senjata Kar98K menggunakan Extended Sniper?
<p v-for="v in vrameworks">
<input type="radio">
{{v.answer}}
</p>
<button type="submit" v-on:Click="skor">Jawab</button>
<h1>Skor : {{skor}}</h1>
<script src="index.js"></script>
</div>
</body>
</html>
I give a true statement in every right answer so if user choose an answer with true statement it should be adding 1 points to the score and print the score, the problem is I get this warning (function () { [native code] }) when I'm trying to print the score, the score should be 0 at first
skorthat's a function, and inside that function you try to add 1 to it. That does not make sense; you need a different property to keep the score value.