From d04b6ac0576dbc2a7695a190a5ed6cdcce82def2 Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 26 Oct 2017 04:31:04 +0300 Subject: [PATCH] Update article.md --- .../02-rest-parameters-spread-operator/article.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/1-js/06-advanced-functions/02-rest-parameters-spread-operator/article.md b/1-js/06-advanced-functions/02-rest-parameters-spread-operator/article.md index eaa42ab9..0788860e 100644 --- a/1-js/06-advanced-functions/02-rest-parameters-spread-operator/article.md +++ b/1-js/06-advanced-functions/02-rest-parameters-spread-operator/article.md @@ -1,6 +1,6 @@ # Rest parameters and spread operator -Many JavaScript built-in functions support on arbitrary number of arguments. +Many JavaScript built-in functions support an arbitrary number of arguments. For instance: @@ -35,7 +35,7 @@ For instance, to gather all arguments into array `args`: function sumAll(...args) { // args is the name for the array let sum = 0; - for(let arg of args) sum += arg; + for (let arg of args) sum += arg; return sum; } @@ -207,7 +207,7 @@ alert( [...str] ); // H,e,l,l,o The spread operator internally uses iterators to gather elements, the same way as `for..of` does. -So, for a string, `for..of` returns characters and `...str` becomes `"h","e","l","l","o"`. The list of characters is passed to array initializer `[...str]`. +So, for a string, `for..of` returns characters and `...str` becomes `"H","e","l","l","o"`. The list of characters is passed to array initializer `[...str]`. For this particular task we could also use `Array.from`, because it converts an iterable (like a string) into an array: