@@ -7,14 +7,14 @@ test("defining functions directly", function() {
77 result = "b" ;
88 } ;
99 changeResult ( ) ;
10- equals ( result , __ , 'what is the value of result?' ) ;
10+ equals ( result , "b" , '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- equals ( triple ( 4 ) , __ , 'what is triple 4?' ) ;
17+ equals ( triple ( 4 ) , 12 , 'what is triple 4?' ) ;
1818} ) ;
1919
2020test ( "self invoking functions" , function ( ) {
@@ -23,22 +23,23 @@ 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- equals ( pv , __ , 'what is the value of pv?' ) ;
27- equals ( typeof ( secretValue ) , "__ " , "is secretValue available in this context?" ) ;
28- equals ( typeof ( publicValue ) , "__ " , "is publicValue available in this context?" ) ;
26+ equals ( pv , "shared" , 'what is the value of pv?' ) ;
27+ equals ( typeof ( secretValue ) , "string " , "is secretValue available in this context?" ) ;
28+ equals ( typeof ( publicValue ) , "string " , "is publicValue available in this context?" ) ;
2929 } ) ( publicValue ) ;
3030
31- equals ( typeof ( secretValue ) , "__ " , "is secretValue available in this context?" ) ;
32- equals ( typeof ( publicValue ) , "__ " , "is publicValue available in this context?" ) ;
31+ equals ( typeof ( secretValue ) , "undefined " , "is secretValue available in this context?" ) ;
32+ equals ( typeof ( publicValue ) , "string " , "is publicValue available in this context?" ) ;
3333} ) ;
3434
3535test ( "arguments array" , function ( ) {
3636 var add = function ( ) {
3737 var total = 0 ;
3838 for ( var i = 0 ; i < arguments . length ; i ++ ) {
39- // complete the implementation of this method so that it returns the sum of its arguments
39+ total += arguments [ i ] // complete the implementation of this method so that it returns the sum of its arguments
4040 }
41- // __
41+ return total ;
42+
4243 } ;
4344
4445 equals ( add ( 1 , 2 , 3 , 4 , 5 ) , 15 , "add 1,2,3,4,5" ) ;
@@ -56,7 +57,7 @@ test("using call to invoke function",function(){
5657 //function, and the arguments to be sent to the function,multiple arguments are separated by commas.
5758 var result = invokee . call ( "I am this!" , "Where did it come from?" ) ;
5859
59- equals ( result , __ , "what will the value of invokee's this be?" ) ;
60+ equals ( result , "I am this!Where did it come from?" , "what will the value of invokee's this be?" ) ;
6061} ) ;
6162
6263test ( "using apply to invoke function" , function ( ) {
@@ -69,6 +70,6 @@ test("using apply to invoke function",function(){
6970 //function and and array of arguments to be passed into the called function.
7071 var result = invokee . apply ( "I am this!" , [ "I am arg1" , "I am arg2" ] ) ;
7172
72- equals ( result , __ , "what will the value of invokee's this be?" ) ;
73+ equals ( result , "I am this!I am arg1I am arg2" , "what will the value of invokee's this be?" ) ;
7374} ) ;
7475
0 commit comments