mirror of https://github.com/sveltejs/svelte
- 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
parent
4f9a260ab1
commit
fff4506047
@ -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…
Reference in new issue