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 _st = str.split("");
    let _aa = [];
    let currentWord = { val: "", count: 0 };
    _st.forEach((el, i) => {
      if (el == currentWord.val) {
        currentWord.count++;
        if (_st[i + 1] != el) {
          if (_st[_st.length - 1] == el) {
            _aa.push(
              currentWord.count > 1
                ? currentWord.count + currentWord.val
                : currentWord.val,
            );
          }
        }
      } else {
        console.log("el = ", el);
        console.log("currentWord.count = ", currentWord.count);
        console.log("currentWord.val = ", currentWord.val);
        _aa.push(
          currentWord.count > 1
            ? currentWord.count + currentWord.val
            : currentWord.val,
        );
        if (el != currentWord.val && _st.length - 1 == i) {
          _aa.push(el);
        }
        currentWord.val = el;
        currentWord.count = 1;
      }
    });
    console.log(_aa.join(""));
    return _aa.join("");
  }
  