Q:

Write a JavaScript program to get the last element from an given array

0

Write a JavaScript program to get the last element from an given array.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

const last = arr => arr[arr.length - 1];
console.log(last([1, 2, 3]));
console.log(last([1, 2, 3, 4, 5, 7]));

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now