text: import { NotImplementedError } from '../extensions/index.js';
  
  /**
   * Given an array of domains, return the object with the appearances of the DNS.
   *
   * @param {Array} domains
   * @return {Object}
   *
   * @example
   * domains = [
   *  'code.yandex.ru',
   *  'music.yandex.ru',
   *  'yandex.ru'
   * ]
   *
   * The result should be the following:
   * {
   *   '.ru': 3,
   *   '.ru.yandex': 3,
   *   '.ru.yandex.code': 1,
   *   '.ru.yandex.music': 1,
   * }
   *
   */
  export default function getDNSStats(array) {
  
    let obj = {};
    
    let modarr = array.map(str => str.split(".").reverse());
    
      for (let i=0;i<modarr.length;i++) {
    
          for (let j=0;j<modarr[i].length;j++) {
            if (j > 0) {
              modarr[i][j]=`${modarr[i][j-1]}.${modarr[i][j]}`;
            }
          }
      }
  
      let farr = [].concat(...modarr);
  
       farr.forEach(elem => { let x = `.${elem}`;
        ( obj[x] ) ? obj[x]++ : obj[x] = 1});
        
         return obj;
        console.log(obj);
    }
  getDNSStats(['epam.com']);
  