fp.js
function nth(list, indexNum) {
    if (arguments.length == 1) {
      // Manually currying
      indexNum = list;
      return (list) => nth(list, indexNum);
    }

    if(indexNum >= 0) {
      return list[+indexNum]
    };
    return [...list].reverse()[list.length+indexNum];
  }
function nth(list, indexNum) {
    if (arguments.length == 1) {
      // Manually currying
      indexNum = list;
      return (list) => nth(list, indexNum);
    }

    if(indexNum >= 0) {
      return list[+indexNum]
    };
    return [...list].reverse()[list.length+indexNum];
  }
function nth ( list , indexNum ) { if ( arguments . length == 1 ) { // Manually currying indexNum = list ; return ( list ) => nth ( list , indexNum ) ; } if ( indexNum >= 0 ) { return list [ + indexNum ] } ; return [ ... list ] . reverse ( ) [ list . length + indexNum ] ; }
Returns the nth value at the specified index.
If index is negative, it returns value starting from the right
@param list the array to be operated on
@param indexNum the index number of the value to be retrieved
Returns the nth value at the specified index . If index is negative it returns value starting from the right