I'm trying to return the last element in an array or, if the array is empty it should return null. What am I doing wrong / what is the best way to do this?
Here's my code:
function lastElement(x, y, z) {
if (lastElement.length < 1 || lastElement === undefined) {
return null;
}
else {
return(lastElement[lastElement.length - 1]);
}
}