From df44da9dc20488fc5c908bd770087e8380216dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lasse=20J=C3=B8rgensen?= <28780271+lasjorg@users.noreply.github.com> Date: Wed, 25 Nov 2020 17:14:33 +0100 Subject: [PATCH] fix(challenge): correct terminology and inform of correct array copying (#40045) * fix(challenge): correct terminology and inform of correct array copying * fix(challenge): update text with proposed changes --- .../refactor-global-variables-out-of-functions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/refactor-global-variables-out-of-functions.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/refactor-global-variables-out-of-functions.md index db04a3bb9b..c191ce5d59 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/refactor-global-variables-out-of-functions.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/refactor-global-variables-out-of-functions.md @@ -8,8 +8,8 @@ forumTopicId: 301235 ## Description
So far, we have seen two distinct principles for functional programming: -1) Don't alter a variable or object - create new variables and objects and return them if need be from a function. -2) Declare function arguments - any computation inside a function depends only on the arguments, and not on any global object or variable. +1) Don't alter a variable or object - create new variables and objects and return them if need be from a function. Hint: using something like var newArr = arrVar, where arrVar is an array will simply create a reference to the existing variable and not a copy. So changing a value in newArr would change the value in arrVar. +2) Declare function parameters - any computation inside a function depends only on the arguments passed to the function, and not on any global object or variable. Adding one to a number is not very exciting, but we can apply these principles when working with arrays or more complex objects.