Create A Nested Array Nestedarray A 2 Dimensional Array Outer Array Has 2 Elements Each Element Of The Outer Array 1 (51.01 KiB) Viewed 35 times
Create a nested array, nestedArray a 2- dimensional array • Outer array has 2 elements • Each element of the outer array must be an array • Each nested (inner) array must have 3 elements in it index.js 1 const nestedArray = []; 2 var cols = 2; 3 var rows = 3; 4. for(var i = 0; i < rows; i++) { 5 nestedArray = ; 6 for(var j = 0; j < cols; j++){ nestedArray[j] j; 8 } } console.log(nestedArray); 11 7 === 9 10 12 13 If our array were a grid, it would contain 2 rows and 3 columns. 14 // DO NOT EDIT BELOW 15 16 modulo avnante - noctodinnou. CONSOLE SHELL This is an example of a grid with 4 rows and 2 columns: = const nestedArray = [ ['o', 'o'], ['o', 'o'], ['o', 'o'], ['o', 'o'] ]; Check Answer Recent Submissions
Each nested array must have 3 elements (0/1 Points) Failed ^ Create a nested imensional ar Summary: Outer array Each elemen 11 L an array Each nested at Object.<anonymous> (index.test.js:8:29) elements in i Test Suites: 1 failed, i total Tests: 1 failed, 1 total Snapshots: 0 total Time: 0.551 s Ran all test suites matching /index.test.js/i. our array wer ows and 3 colu his is an exam nd 2 columns Has 2 elements (0/1 Points) Failed All elements must be arrays (1/1 Points) Passed const nested ['o', 'o'] ['o', 'o'] ['o', 'o'] ['o', 'o'] ]; Is an Array (1/1 Points) Passed v
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!