Write a JavaScript program to get the last element from an given array.
const last = arr => arr[arr.length - 1]; console.log(last([1, 2, 3])); console.log(last([1, 2, 3, 4, 5, 7]));
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
need an explanation for this answer? contact us directly to get an explanation for this answer