From f55916cac09caa85b8ed685edad27bc0716b9d25 Mon Sep 17 00:00:00 2001 From: Alex LaFroscia Date: Tue, 25 Oct 2016 18:22:00 -0700 Subject: [PATCH] Update Purity code examples to use interpolation Also, add in the missing argument to `greet` in the changing-global-state example code. --- readme.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/readme.md b/readme.md index 7b91f4a..dc4ecdc 100644 --- a/readme.md +++ b/readme.md @@ -179,7 +179,7 @@ A function is pure if the return value is only determined by its input values, and does not produce side effects. ```js -const greet = (name) => 'Hi, ' + name +const greet = (name) => `Hi, ${name}` greet('Brianne') // 'Hi, Brianne' ``` @@ -189,9 +189,7 @@ As opposed to each of the following: ```js window.name = 'Brianne' -const greet = () => { - return 'Hi, ' + window.name -} +const greet = () => `Hi, ${window.name}` greet() // "Hi, Brianne" ``` @@ -202,10 +200,10 @@ The above example's output is based on data stored outside of the function... let greeting const greet = (name) => { - greeting = 'Hi, ' + name + greeting = `Hi, ${name}` } -greet() +greet('Brianne') greeting // "Hi, Brianne" ```