File tree Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change 11function printElements ( arr ) {
2- for ( let i = 0 ; i < arr . length ; i ++ ) {
3- if ( Array . isArray ( arr [ i ] ) ) {
4- // Recursive case: if the element is an array, go deeper
5- printElements ( arr [ i ] ) ;
6- } else {
7- // Base case: if the element is not an array, print it
8- console . log ( arr [ i ] ) ;
9- }
2+ for ( let i = 0 ; i < arr . length ; i ++ ) {
3+ if ( Array . isArray ( arr [ i ] ) ) {
4+ // Recursive case: if the element is an array, go deeper
5+ printElements ( arr [ i ] )
6+ } else {
7+ // Base case: if the element is not an array, print it
8+ console . log ( arr [ i ] )
109 }
10+ }
1111}
1212const multiDimensionalArray = [
13- [ 1 , 2 , [ 3 , 4 ] ] ,
14- [ 5 , 6 ] ,
15- [ [ 7 , 8 ] , 9 ]
16- ] ;
13+ [ 1 , 2 , [ 3 , 4 ] ] ,
14+ [ 5 , 6 ] ,
15+ [ [ 7 , 8 ] , 9 ]
16+ ]
1717
18- printElements ( multiDimensionalArray ) ;
18+ printElements ( multiDimensionalArray )
You can’t perform that action at this time.
0 commit comments