kthFromEnd(k) {
    if (k instanceof Number) {
      k = Number(k);
    }
    if (typeof k !== 'number' || k % 1 !== 0) {
      throw new TypeError('Index must be an integer');
    }
    if (k < 0 || k >= this.length) {
      throw new ReferenceError();
    }
    if (k === 0) {
      return this.tail.value;
    }
    let current = this.head;
    for (let i = 0; i < this.length - k - 1; i++) {
      current = current.next;
    }
    return current.value;
  }
/**
   * Finds an element starting from the end of the list.
   * @param {int} k index, from the end of the list, of element to find
   * @returns {*} Value of the requested element
   */
Finds an element starting from the end of the list.
@param {int} k index, from the end of the list, of element to find
@returns {*} Value of the requested element
Finds an element starting from the end of the list . @param { int } k index from the end of the list of element to find @returns { * } Value of the requested element
kthFromEnd(k) {
    if (k instanceof Number) {
      k = Number(k);
    }
    if (typeof k !== 'number' || k % 1 !== 0) {
      throw new TypeError('Index must be an integer');
    }
    if (k < 0 || k >= this.length) {
      throw new ReferenceError();
    }
    if (k === 0) {
      return this.tail.value;
    }
    let current = this.head;
    for (let i = 0; i < this.length - k - 1; i++) {
      current = current.next;
    }
    return current.value;
  }
kthFromEnd ( k ) { if ( k instanceof Number ) { k = Number ( k ) ; } if ( typeof k !== 'number' || k % 1 !== 0 ) { throw new TypeError ( 'Index must be an integer' ) ; } if ( k < 0 || k >= this . length ) { throw new ReferenceError ( ) ; } if ( k === 0 ) { return this . tail . value ; } let current = this . head ; for ( let i = 0 ; i < this . length - k - 1 ; i ++ ) { current = current . next ; } return current . value ; }
Finds an element starting from the end of the list.
Finds an element starting from the end of the list .