Add dynamic condition result example

I added the dynamic condition result example. It would be nice to showing this basic example on the tutorial, Svelte can do many things that is easy to understand even with the beginner.
pull/7278/head
jakasulthon 5 years ago committed by GitHub
parent 39f0d8cc31
commit 3d53272062
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -13,3 +13,23 @@ Multiple conditions can be 'chained' together with `else if`:
<p>{x} is between 5 and 10</p> <p>{x} is between 5 and 10</p>
{/if} {/if}
``` ```
Also, you can add some increment function to variable `x` so it will dynamically change the condition output.
Add the `Add number` button with event function `incrementNumber`:
```html
<button on:click={incrementNumber}>
Add number
</button>
```
Change variable `x` to increment itself inside the function `incrementNumber`:
```js
function incrementNumber() {
x += 1;
};
```
Voila! Now you can see the condition output changes as `Add number` constantly clicked.

Loading…
Cancel
Save