29 lines
490 B
JavaScript
29 lines
490 B
JavaScript
const app = Vue.createApp({
|
|
data: () => ({
|
|
sum: 0,
|
|
timeout: null,
|
|
}),
|
|
methods: {
|
|
add(amount) {
|
|
this.sum += amount;
|
|
},
|
|
},
|
|
computed: {
|
|
result() {
|
|
if (this.sum < 37) return "Not there yet";
|
|
if (this.sum > 37) return "Too much!";
|
|
return this.number;
|
|
},
|
|
},
|
|
watch: {
|
|
sum() {
|
|
clearTimeout(this.timeout);
|
|
this.timeout = setTimeout(() => {
|
|
this.sum = 0;
|
|
}, 5000);
|
|
},
|
|
},
|
|
});
|
|
|
|
app.mount("#assignment");
|