Slight improvement to code brevity

- the change improves the brevity of the code, which is a big leitmotif of Svelte's
  -  a live preview of the button is already available right below the source code, meaning readibility isn't really impacted
    - doubly so since the current version already uses a ternary operator
  - the function expression in the proposal also addresses the inconsistent semicolon usage in the current version of the file

As a side note, since this tutorial is largely targeting newcomers to JS, maybe calling the function something like "plusOne" would be preferable over intimidating people with three-syllable words like "increment". ECMAScript can be scary enough as it is and educational materials should definitely take such UX factors into consideration; they all add up to something greater than a sum of its parts. :)
pull/6713/head
Dominik Bošnjak 5 years ago committed by GitHub
parent 4f9a260ab1
commit fff4506047
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,11 +1,8 @@
<script>
let count = 0;
function incrementCount() {
count += 1;
}
const incrementCount = () => count++;
</script>
<button on:click={incrementCount}>
Clicked {count} {count === 1 ? 'time' : 'times'}
Clicked {count} time{count !== 1 ? 's' : ''}
</button>

Loading…
Cancel
Save