Last active
August 30, 2018 13:01
-
-
Save IsTheJack/d8fdbd31e6fb7fc0af3db24017fcd243 to your computer and use it in GitHub Desktop.
A função 'getLast' retorna o último elemento de uma array sem causar nenhuma exceção ou qualquer tipo de warning. Qual melhoria você faria nessa função. Por que?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get the last element of an array | |
* @function getLast | |
* @argument {Array} arr | |
* @returns | |
*/ | |
const getLast = arr => arr.pop() | |
const numbers = [1, 2, 3, 4, 5] | |
console.log(getLast(numbers)) // => 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment