index.js
/**
 * last: check to see if the number is in an array will bring out the number of elements desired, or
 *      [], or last element in array
 * 
 * @param {Array} array: any array that will be tested 
 * @param {number} x: the number that will be passed to test if it is a number in the array
 * 
 * @return {array}: if the number is a negative it will return []
 * @return {array}: if the number is not given or not a number it will return the last element in the array
 * @return {array}: if number given is greater than the array's length it will return the whole array 
 * @return {array}: will return an array's elements up to the given number to the end it will return a modified array
 */
check to see if the number is in an array will bring out the number of elements desired, or
[], or last element in array

@param {Array} array: any array that will be tested
@param {number} x: the number that will be passed to test if it is a number in the array

@return {array}: if the number is a negative it will return []
@return {array}: if the number is not given or not a number it will return the last element in the array
@return {array}: if number given is greater than the array's length it will return the whole array
@return {array}: will return an array's elements up to the given number to the end it will return a modified array
check to see if the number is in an array will bring out the number of elements desired or [] or last element in array @param { Array } array : any array that will be tested @param { number } x : the number that will be passed to test if it is a number in the array @return { array } : if the number is a negative it will return [] @return { array } : if the number is not given or not a number it will return the last element in the array @return { array } : if number given is greater than the array ' s length it will return the whole array @return { array } : will return an array ' s elements up to the given number to the end it will return a modified array
function last(array, x){
    if (!Array.isArray(array) || x < 0) {
      return [];
    }
    return x === undefined ? array[array.length - 1] : array.slice(-x , array.length);
}
function last ( array , x ) { if ( ! Array . isArray ( array ) || x < 0 ) { return [ ] ; } return x === undefined ? array [ array . length - 1 ] : array . slice ( - x , array . length ) ; }
last: check to see if the number is in an array will bring out the number of elements desired, or
      [], or last element in array
last : check to see if the number is in an array will bring out the number of elements desired or [] or last element in array