From 0813b4645b2d55131d920c45834a93626d7855f1 Mon Sep 17 00:00:00 2001 From: Pier Bover Date: Mon, 22 Apr 2019 11:49:02 -0500 Subject: [PATCH 1/3] Clarification of array example --- .../02-reactivity/04-updating-arrays-and-objects/text.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/site/content/tutorial/02-reactivity/04-updating-arrays-and-objects/text.md b/site/content/tutorial/02-reactivity/04-updating-arrays-and-objects/text.md index 0a78c7ca32..22b43c1931 100644 --- a/site/content/tutorial/02-reactivity/04-updating-arrays-and-objects/text.md +++ b/site/content/tutorial/02-reactivity/04-updating-arrays-and-objects/text.md @@ -7,8 +7,8 @@ Because Svelte's reactivity is triggered by assignments, using array methods lik One way to fix that is to add an assignment that would otherwise be redundant: ```js -function addNumber() { - numbers.push(numbers.length + 1); +function addNumber(value) { + numbers.push(value); numbers = numbers; } ``` @@ -16,8 +16,8 @@ function addNumber() { But there's a more *idiomatic* solution: ```js -function addNumber() { - numbers = [...numbers, numbers.length + 1]; +function addNumber(value) { + numbers = [...numbers, value]; } ``` From 67bd3a56fc369ddc413f5c89514e4d5fdaa936e1 Mon Sep 17 00:00:00 2001 From: Pier Bover Date: Mon, 22 Apr 2019 11:54:03 -0500 Subject: [PATCH 2/3] Added value to code example So that it is more consistent with the tutorial text. --- .../04-updating-arrays-and-objects/app-a/App.svelte | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/site/content/tutorial/02-reactivity/04-updating-arrays-and-objects/app-a/App.svelte b/site/content/tutorial/02-reactivity/04-updating-arrays-and-objects/app-a/App.svelte index 74b11d2399..ae398acbe0 100644 --- a/site/content/tutorial/02-reactivity/04-updating-arrays-and-objects/app-a/App.svelte +++ b/site/content/tutorial/02-reactivity/04-updating-arrays-and-objects/app-a/App.svelte @@ -1,8 +1,8 @@