Retornar o último item
Retorne o último item de um array, ou o caractere final de uma string. Para uma entrada vazia, retorne undefined.
Exemplos
lastItem([0, 4, 19, 34, 50, -9, 2]) ➞ 2
lastItem("The quick brown fox jumped over the lazy dog") ➞ "g"
lastItem([]) ➞ undefinedObservações
- Arrays e strings terão tamanhos variados.
- Retorne
undefinedse o array ou a string estiverem vazios.