Quitando las capas exteriores
Dado un arreglo de arreglos de objetos, devuelve un nuevo arreglo de arreglos de objetos que contenga todos los elementos, excepto los elementos exteriores.
Ejemplos
peelLayer([
['a', 'b', 'c', 'd'],
['e', 'f', 'g', 'h'],
['i', 'j', 'k', 'l'],
['m', 'n', 'o', 'p']
]) ➞ [
['f', 'g'],
['j', 'k']
]
peelLayer([
[1, 2, 3, 4, 5],
[6, 7, 8, 9, 10],
[11, 12, 13, 14, 15],
[16, 17, 18, 19, 20],
[21, 22, 23, 24, 25],
[26, 27, 28, 29, 30],
[31, 32, 33, 34, 35]
]) ➞ [
[7, 8, 9],
[12, 13, 14],
[17, 18, 19],
[22, 23, 24],
[27, 28, 29]
]
peelLayer([
[true, false, true],
[false, false, true],
[true, true, true]
]) ➞ [[false]]
peel_layer_off([
["hello", "world"],
["hello", "world"]
]) ➞ []Notas
- La cuadrícula 2D siempre tiene una forma rectangular/cuadrada.
- Devuelve siempre algún tipo de arreglo anidado, a menos que no haya elementos. En ese caso, devuelve un arreglo vacío.