@@ -7,14 +7,14 @@ test("defining functions directly", function() {
77 result = "b" ;
88 } ;
99 changeResult ( ) ;
10- equal ( __ , result , 'what is the value of result?' ) ;
10+ equal ( "b" , result , 'what is the value of result?' ) ;
1111} ) ;
1212
1313test ( "assigning functions to variables" , function ( ) {
1414 var triple = function ( input ) {
1515 return input * 3 ;
1616 } ;
17- equal ( __ , triple ( 4 ) , 'what is triple 4?' ) ;
17+ equal ( 12 , triple ( 4 ) , 'what is triple 4?' ) ;
1818} ) ;
1919
2020test ( "self invoking functions" , function ( ) {
@@ -23,13 +23,13 @@ test("self invoking functions", function() {
2323 // self invoking functions are used to provide scoping and to alias variables
2424 ( function ( pv ) {
2525 var secretValue = "password" ;
26- equal ( __ , pv , 'what is the value of pv?' ) ;
27- equal ( "__ " , typeof ( secretValue ) , "is secretValue available in this context?" ) ;
28- equal ( "__ " , typeof ( publicValue ) , "is publicValue available in this context?" ) ;
26+ equal ( "shared" , pv , 'what is the value of pv?' ) ;
27+ equal ( "string " , typeof ( secretValue ) , "is secretValue available in this context?" ) ;
28+ equal ( "string " , typeof ( publicValue ) , "is publicValue available in this context?" ) ;
2929 } ) ( publicValue ) ;
3030
31- equal ( "__ " , typeof ( secretValue ) , "is secretValue available in this context?" ) ;
32- equal ( "__ " , typeof ( publicValue ) , "is publicValue available in this context?" ) ;
31+ equal ( "undefined " , typeof ( secretValue ) , "is secretValue available in this context?" ) ;
32+ equal ( "string " , typeof ( publicValue ) , "is publicValue available in this context?" ) ;
3333} ) ;
3434
3535test ( "arguments array" , function ( ) {
@@ -38,8 +38,10 @@ test("arguments array", function() {
3838 for ( var i = 0 ; i < arguments . length ; i ++ ) {
3939 // complete the implementation of this method so that it returns the sum of its arguments
4040 // __
41+ total += arguments [ i ] ;
4142 }
4243 // __
44+ return total ;
4345 } ;
4446
4547 equal ( 15 , add ( 1 , 2 , 3 , 4 , 5 ) , "add 1,2,3,4,5" ) ;
@@ -48,28 +50,27 @@ test("arguments array", function() {
4850
4951test ( "using call to invoke function" , function ( ) {
5052 var invokee = function ( message ) {
51- return this + message ;
53+ return this + message ;
5254 } ;
53-
54- //another way to invoke a function is to use the call function which allows
55- //you to set the callers "this" context. Call can take any number of arguments:
55+
56+ //another way to invoke a function is to use the call function which allows
57+ //you to set the callers "this" context. Call can take any number of arguments:
5658 //the first one is always the context that this should be set to in the called
5759 //function, and the arguments to be sent to the function,multiple arguments are separated by commas.
5860 var result = invokee . call ( "I am this!" , "Where did it come from?" ) ;
59-
60- equal ( __ , result , "what will the value of invokee's this be?" ) ;
61+
62+ equal ( "I am this!Where did it come from?" , result , "what will the value of invokee's this be?" ) ;
6163} ) ;
6264
6365test ( "using apply to invoke function" , function ( ) {
6466 var invokee = function ( message1 , message2 ) {
65- return this + message1 + message2 ;
67+ return this + message1 + message2 ;
6668 } ;
67-
69+
6870 //similar to the call function is the apply function. Apply only has two
6971 //arguments: the first is the context that this should be set to in the called
7072 //function and the second is the array of arguments to be passed into the called function.
7173 var result = invokee . apply ( "I am this!" , [ "I am arg1" , "I am arg2" ] ) ;
72-
73- equal ( __ , result , "what will the value of invokee's this be?" ) ;
74- } ) ;
7574
75+ equal ( "I am this!I am arg1I am arg2" , result , "what will the value of invokee's this be?" ) ;
76+ } ) ;
0 commit comments