EDABIT:Return the Last Item in an Array
Return the Last Item in an Array
Examples
[1, 2, 3] ➞ 3
['cat', 'dog', 'duck'] ➞ 'duck'
[true, false, true] ➞ true
Notes
- Don't forget to
returnthe result. - All test cases contain valid data types.
- If you get stuck on a challenge, find help in the Resources tab.
- If you're really stuck, unlock solutions in the Solutions tab.
function getLastItem(arr) {
var c = arr.pop();
return c;
}
Comments
Post a Comment