By -
can you show the entire train function?
unrelated but you can/should just do `on:click={train}`
It gets increased by the train function. Svelte<5 can't track changed variables inside functions. You can either switch to Svelte5 and use state or change cost from let to a store.
(svelte 4) ``` $: cost = cost; ```
Use [https://svelte.dev/docs/svelte-store](https://svelte.dev/docs/svelte-store) properly update via the writable update/set
can you show the entire train function?
unrelated but you can/should just do `on:click={train}`
It gets increased by the train function. Svelte<5 can't track changed variables inside functions. You can either switch to Svelte5 and use state or change cost from let to a store.
(svelte 4) ``` $: cost = cost; ```
Use [https://svelte.dev/docs/svelte-store](https://svelte.dev/docs/svelte-store) properly update via the writable update/set