Question 15
Consider the following HTML with relevant Vue CDN attached.
<div id="app"> <input v-model.number="price" type="number"> <input v-model.number="quantity" type="number"> <p>Total: {{ total }}</p> <p>Last Updated By: {{ lastUpdatedBy }}</p></div>
<script> new Vue({ el: '#app', data: { price: 10, quantity: 1, total: 10, lastUpdatedBy: 'initial' }, watch: { price: { handler(newVal) { this.total = newVal * this.quantity; this.lastUpdatedBy = 'price'; } }, quantity: { handler(newVal) { this.total = this.price * newVal; this.lastUpdatedBy = 'quantity'; } } } }) </script>If the user changes the price to 20 and then immediately changes the quantity to 2, what will be the final values of total and lastUpdatedBy?
total: 20, lastUpdatedBy: "price"
total: 40, lastUpdatedBy: "quantity"
total: 20, lastUpdatedBy: "quantity"
total: 40, lastUpdatedBy: "price"