@@ -9,16 +9,16 @@ Arrow functions create a concise expression that encapsulates a small piece of f
99For example:
1010
1111``` javascript
12- // const multiply = function(x,y) {
13- // return x * y;
14- // }
12+ // const multiply = function(x,y) {
13+ // return x * y;
14+ // }
1515
1616// Can be rewritten as:
1717// const multiply = (x, y) => { return x * y };
1818
1919// Since the function is a single expression return and braces are not needed:
2020const multiply = (x , y ) => x * y;
21- console .log (multiply (5 ,10 )) // 50
21+ console .log (multiply (5 ,10 )) // 50
2222```
2323
2424<a href =" https://codepen.io/Bunlong/pen/QBgdJb " target =" _blank " >Edit on Codepen</a >
@@ -46,11 +46,20 @@ For example:
4646Statement
4747
4848``` javascript
49- 49+ const getSalutation = function (hour ) {
50+ var salutation; // temp value
51+ if (hour < 12 ) {
52+ salutation = " Good Morning" ;
53+ } else {
54+ salutation = " Good Afternoon"
55+ }
56+ return salutation; // mutated value
57+ }
5058```
5159
5260Expression
5361
5462``` javascript
55- 63+ const getSalutation = (hour ) => hour < 12 ? " Good Morning" : " Good Afternoon" ;
64+ console .log (getSalutation (10 )); // Good Morning
5665```
0 commit comments