1function getLength(array) {
2 return 0 in array ? 1 + getLength(array.slice(1)) : 0;
3}
4
5console.log(getLength([1])); // 1
6console.log(getLength([1, 2])); // 2
7console.log(getLength([1, 2, 3, 4, 5])); // 5
8console.log(getLength([], 0)); // 0