scrimba
Note at 0:50
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Note at 0:50
AboutCommentsNotes
Note at 0:50
Expand for more info
main.js
run
preview
console
function extractMatrixColumn(matrix, column) {
return matrix.map((innerArray) => innerArray[column] )
}



/**
* Test Suite
*/
describe('extractMatrixColumn()', () => {
it('returns the element from nested arrays at column (index)', () => {
// arrange
const matrix = [[1, 1, 1, 2], [0, 5, 0, 4], [2, 1, 3, 6]];
const column = 2;

// act
const result = extractMatrixColumn(matrix, column);

// log
console.log("result: ", result);

// assert
expect(result).toEqual([1, 0, 3]);
});
it('returns the element from nested arrays at column (index)', () => {
// arrange
const matrix = [[1, 2, 3, 4], [5, 6, 7], [8, 9, 10, 11, 12]];
const column = 2;

// act
const result = extractMatrixColumn(matrix, column);

// log
console.log("result: ", result);

// assert
expect(result).toEqual([3, 7, 10]);
});
});
Console
"result: "
,
[
1
,
0
,
3
]
,
"result: "
,
[
3
,
7
,
10
]
,
/index.html
LIVE