JavaScript function to get the last 'n' elements of the array | JavaScript

preview_player
Показать описание
Write a JavaScript function to get the last 'n' elements of the array. If array has 6 elements and if user gives 4, it has to return last 4 elements. If user gives ‘n’ which is greater than the number of elements in the array, then it should return all elements.
Рекомендации по теме