text: import { NotImplementedError } from '../extensions/index.js';
  
  /**
   * Given a string, return its encoding version.
   *
   * @param {String} str
   * @return {String}
   *
   * @example
   * For aabbbc should return 2a3bc
   *
   */
  export default function encodeLine(str) {
    let line = '';
    let k = 1;
    for (let i = 0; i < str.length; i++) {
      if (str[i] === str[i + 1]) {
        k++;
      } if (str[i] !== str[i + 1] && k >= 2) {
        line += k + str[i];
        k = 1;
      } else if (str[i] !== str[i + 1]) {
        line += str[i];
      }
      if (str[i] !== str[i + 1] && i + 1 === str.length - 1) {
        line += str[i + 1];
        return line;
      }
    }
    return line;
  
  }
  