--- title: Identity matrix id: 5a23c84252665b21eecc7eb1 challengeType: 5 videoUrl: '' localeTitle: Matriz de identidad --- ## Description
Una matriz de identidad es una matriz cuadrada de tamaño \ (n \ tiempos n \), donde los elementos diagonales son todos 1 s (unos), y todos los demás elementos son todos 0 s (ceros). \ begin {bmatrix} 1 & 0 & 0 \ cr 0 & 1 & 0 \ cr 0 & 0 & 1 \ cr \ end {bmatrix} Escriba una función que tome un número 'n' como parámetro y devuelva la matriz de identidad de orden nx n.
## Instructions
## Tests
```yml tests: - text: idMatrix debería ser una función. testString: 'assert(typeof idMatrix=="function","idMatrix should be a function.");' - text: idMatrix(1) debería devolver una matriz. testString: 'assert(Array.isArray(idMatrix(1)),"idMatrix(1) should return an array.");' - text: 'idMatrix(1) debe devolver "+JSON.stringify(results[0])+" .' testString: 'assert.deepEqual(idMatrix(1),results[0],"idMatrix(1) should return "+JSON.stringify(results[0])+".");' - text: 'idMatrix(2) debe devolver "+JSON.stringify(results[1])+" .' testString: 'assert.deepEqual(idMatrix(2),results[1],"idMatrix(2) should return "+JSON.stringify(results[1])+".");' - text: 'idMatrix(3) debe devolver "+JSON.stringify(results[2])+" .' testString: 'assert.deepEqual(idMatrix(3),results[2],"idMatrix(3) should return "+JSON.stringify(results[2])+".");' - text: 'idMatrix(4) debe devolver "+JSON.stringify(results[3])+" .' testString: 'assert.deepEqual(idMatrix(4),results[3],"idMatrix(4) should return "+JSON.stringify(results[3])+".");' ```
## Challenge Seed
```js function idMatrix (n) { // Good luck! } ```
### After Test
```js console.info('after the test'); ```
## Solution
```js // solution required ```