File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11"use strict" ;
22
3- var circleArea1 = function ( r ) {
3+ function circleArea ( r ) {
44 var PI = 3.14 ;
5- var area = PI * r * r ;
6- return area ;
7- } ;
5+ return PI * r * r ;
6+ }
87
9- let circleArea2 = ( r ) => {
8+ // we can now leave out the "function" keyword
9+ let circleArea1 = ( r ) => {
1010 const PI = 3.14 ;
11- let area = PI * r * r ;
12- return area ;
11+ return PI * r * r ;
1312} ;
1413
15- let circleArea3 = ( r ) => 3.14 * r * r ;
14+ // parenthesis are optional is there is one parameter
15+ // we can also leave out the curly braces to return a value directly (without needing multiple statements)
16+ let circleArea2 = r => 3.14 * r * r ;
1617
18+ console . log ( circleArea ( 7 ) ) ;
1719console . log ( circleArea1 ( 7 ) ) ;
1820console . log ( circleArea2 ( 7 ) ) ;
19- console . log ( circleArea3 ( 7 ) ) ;
Original file line number Diff line number Diff line change 11# let
22
33The let statement declares a block scope local variable.
4+
5+ # const
6+
7+ The const declaration creates a read-only reference to a value. It does not mean the value it holds is immutable, just
8+ that the variable identifier cannot be reassigned.
Original file line number Diff line number Diff line change @@ -7,21 +7,21 @@ function theNotebook() {
77 return movie ;
88}
99
10- function randomFunction ( ) {
11- let isFan = true ;
12- let phrase = 'Bacon is good' ;
13- console . log ( '\nBefore if:' , phrase ) ;
10+ console . log ( movie ) ; // Good Will Hunting
11+ console . log ( theNotebook ( ) ) ; // The Notebook
12+ console . log ( movie ) ; // Good Will Hunting
13+
14+ function buckysFunction ( ) {
15+ let isHorse = true ;
16+ let saying = 'Bacon is good' ;
17+ console . log ( '\nBefore if:' , saying ) ;
1418
15- if ( isFan ) {
16- let phrase = 'I am a horse' ;
17- console . log ( 'Inside if:' , phrase ) ;
19+ if ( isHorse ) {
20+ let saying = 'I am a horse' ;
21+ console . log ( 'Inside if:' , saying ) ;
1822 }
1923
20- console . log ( 'After if:' , phrase ) ;
24+ console . log ( 'After if:' , saying ) ;
2125}
2226
23- console . log ( movie ) ; // Good Will Hunting
24- console . log ( theNotebook ( ) ) ; // The Notebook
25- console . log ( movie ) ; // Good Will Hunting
26-
27- randomFunction ( ) ;
27+ buckysFunction ( ) ;
You can’t perform that action at this time.
0 commit comments