File tree Expand file tree Collapse file tree 6 files changed +7
-75
lines changed Expand file tree Collapse file tree 6 files changed +7
-75
lines changed Original file line number Diff line number Diff line change 1- ( function ( ) {
2- function greeter ( str , arr ) {
3- var counter ;
4- for ( counter = 0 ; counter < arr . length ; counter ++ ) {
5- console . log ( str + " " + arr [ counter ] ) ;
6- }
7- }
81
9- greeter ( "Hello" , [ "Fred" , "Judy" ] ) ;
2+
103 // Hello Fred
114 // Hello Judy
12- } ( ) ) ;
135
14- console . log ( window . greeter ) ;
6+
7+
158// undefined
169
17- window . greeter ( "Hello" , [ "Fred" , "Judy" ] ) ;
10+
1811// error TypeError: window.greeter is not a function
Original file line number Diff line number Diff line change 1- function greeter ( str , arr ) {
2- var counter ;
3- var phrase ;
4- for ( counter = 0 ; counter < arr . length ; counter ++ ) {
5- phrase = str + " " + arr [ counter ] ;
6- console . log ( shout ( phrase ) ) ;
7- }
81
9- function shout ( words , emphasis ) {
10- var punctuation = emphasis ;
11- if ( ! punctuation ) {
12- punctuation = "!" ;
13- }
14- return ( words . toUpperCase ( ) + punctuation ) ;
15- }
16- }
17-
18- greeter ( "Hello" , [ "Fred" , "Judy" ] ) ;
192// "HELLO FRED!"
203// "HELLO JUDY!"
Original file line number Diff line number Diff line change 1- var greeter = function ( str , arr , display ) {
2- var counter ;
3- var output ;
4- for ( counter = 0 ; counter < arr . length ; counter ++ ) {
5- output = display ( str + " " + arr [ counter ] ) ;
6- console . log ( output ) ;
7- }
8- } ;
91
10- greeter ( "Hello" , [ "Fred" , "Judy" ] , function ( str ) {
11- return ( str ) ;
12- } ) ;
132// Hello Fred
143// Hello Judy
154
16- greeter ( "Hello" , [ "Fred" , "Judy" ] , function ( str ) {
17- return ( str . toUpperCase ( ) + "!!!" ) ;
18- } ) ;
5+
196// "HELLO FRED!!!"
207// "HELLO JUDY!!!"
Original file line number Diff line number Diff line change 1- var greeter = function ( str , arr ) {
2- var counter ;
3- for ( counter = 0 ; counter < arr . length ; counter ++ ) {
4- console . log ( str + " " + arr [ counter ] ) ;
5- }
6- } ;
71
8- greeter ( "Hello" , [ "Fred" , "Judy" ] ) ;
92// Hello Fred
103// Hello Judy
Original file line number Diff line number Diff line change 1- var greeter = function ( str , arr , display ) {
2- var counter ;
3- var output ;
4- for ( counter = 0 ; counter < arr . length ; counter ++ ) {
5- output = display ( str + " " + arr [ counter ] ) ;
6- console . log ( output ) ;
7- }
8- } ;
91
10- var say = function ( str ) {
11- return ( str ) ;
12- } ;
13-
14- var shout = function ( str ) {
15- return ( str . toUpperCase ( ) + "!!!" ) ;
16- } ;
17-
18- greeter ( "Hello" , [ "Fred" , "Judy" ] , say ) ;
192// Hello Fred
203// Hello Judy
214
22- greeter ( "Hello" , [ "Fred" , "Judy" ] , shout ) ;
5+
236// "HELLO FRED!!!"
247// "HELLO JUDY!!!"
Original file line number Diff line number Diff line change 1- function greeter ( str , arr ) {
2- var counter ;
3- for ( counter = 0 ; counter < arr . length ; counter ++ ) {
4- console . log ( str + " " + arr [ counter ] ) ;
5- }
6- }
71
8- console . log ( window . greeter ) ;
92// the code of the function greeter
103
11- window . greeter ( "Hello" , [ "Fred" , "Judy" ] ) ;
4+
125// Hello Fred
136// Hello Judy
You can’t perform that action at this time.
0 commit comments