А потом, если я хочу предупредить, когда сумма счета (четия + другое) достигнет 10, как я могу это сделать. Этот код не работает.
<script>
var name;
var count = {
cetiya : 0,
other : 0,
sum : count.cetiya + count.other
};
$: if(count.sum >= 10) {
alert('count can't over 10);
}
function addNumPray(name) {
console.log(name);
if (name == "cetiya") {
count.cetiya += 1;
} else {
count.other += 1;
}
}
function minusNumPray(name) {
console.log(name);
if (name == "cetiya") {
count.cetiya -= 1;
} else {
count.other -= 1;
}
}
</script>
<div>
<button on:click={() => minusNumPray("cetiya")}>-</button>
<input type="text" name="numPrayAtCetiya" size="7" bind:value={count.cetiya}>
<button on:click={() => addNumPray("cetiya")}>+</button>
</div>
<div>
<button on:click={() => minusNumPray("other")}>-</button>
<input type="text" name="numPrayAtOther" size="7" bind:value={count.other}>
<button on:click={() => addNumPray("other")}>+</button>
</div>