function testForOf ( ) { let arr = [ 1 , 7 , 8 ] ; let sum = 0 ; for ( let e of arr ) { msg ( "FO:" + e ) ; sum += ( e - 1 ) ; } assert ( sum == 13 , "fo1" ) ; msg ( "loop1 done" ) ; for ( let q of [ 3 , 4 , 12 ] ) { sum += ( q - 2 ) ; } assert ( sum == 26 , "fo2" ) ; let s = "hello, world!" ; let s2 = "" ; for ( let c of s ) { s2 += c ; } assert ( s == s2 , "fo3" ) ; let fibs = [ 0 , 1 ] ; for ( let x of fibs ) { if ( fibs . length < 10 ) { fibs . push ( fibs [ fibs . length - 2 ] + fibs [ fibs . length - 1 ] ) ; } } assert ( fibs . length == 10 , "fo4" ) ; let xs = [ 10 , 9 , 8 ] ; for ( let x of xs ) { assert ( xs . removeElement ( x ) , "fo5" ) ; } let yss = [ [ 1 , 2 , 3 ] , [ 4 , 5 ] , [ 6 , 7 , 8 ] , [ 9 , 10 ] ] ; let concat = [ ] ; for ( let ys of yss ) { for ( let y of ys ) { concat . push ( y ) ; } } assert ( concat . length == 10 , "fo6" ) ; sum = 0 ; for ( let y of concat ) { sum += y ; } assert ( sum == 55 , "fo7" ) ; let f = [ ] ; glb1 = 0 ; for ( const q of [ 1 , 12 ] ) { f . push ( ( ) => { glb1 += q ; } ) ; } f [ 0 ] ( ) ; f [ 1 ] ( ) ; assert ( glb1 == 13 , "foc" ) ; msg ( "for of done" ) ; } testForOf ( ) ;