correct based on the solution
This commit is contained in:
parent
942a45783a
commit
b562250178
|
@ -3,31 +3,31 @@
|
|||
const app = Vue.createApp({
|
||||
data() {
|
||||
return {
|
||||
result: 0,
|
||||
counter: 0,
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
result() {
|
||||
status() {
|
||||
const that = this;
|
||||
setTimeout(function () {
|
||||
that.result = 0;
|
||||
that.counter = 0;
|
||||
}, 5000);
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
status() {
|
||||
if (this.result < 37) {
|
||||
if (this.counter < 37) {
|
||||
return "Not there yet";
|
||||
} else if (this.result > 37) {
|
||||
} else if (this.counter > 37) {
|
||||
return "Too much!";
|
||||
} else if (this.result === 37) {
|
||||
return this.result;
|
||||
} else if (this.counter === 37) {
|
||||
return this.counter;
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
increaseCounter(value) {
|
||||
this.result += value;
|
||||
this.counter += value;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -21,8 +21,7 @@
|
|||
<!-- 1) Connect the buttons and calculate a value (a number) -->
|
||||
<!-- Show "Not there yet" until you reach a result of exactly 37 -->
|
||||
<!-- Show "Too much!" if the result is greater than 37 -->
|
||||
<p>{{ status }}</p>
|
||||
<p>Result: {{ result }}</p>
|
||||
<p>Result: {{ status }}</p>
|
||||
<!-- 2) Watch for changes in "result" and reset the value to 0 after 5 seconds -->
|
||||
</section>
|
||||
</body>
|
||||
|
|
Reference in New Issue