List all direct and indirect employees of a manager
Review

You shouldn't put a function definition inside of another function like that. It means it has to recreate the function every time. It would be better to not get in a habit of that.
Same goes for the contants ceo, etc.
In addition, your code only works for one test case, as you manually check for each member.

Rewrite:

const [addEmployee, getEmplyeeBelows] = (function() {
   class Employee {
      constructor(name, id, manager) {
        this.name = name;
        this.id = id;
        this.manager = manager;
        this.manager = registry[manager];
    }
   }
   const registry = {};
   function addEmployee(name, number, parent) {
      if( parent === null ) {
         registry[name] = new Employee(name, number, parent);
      } else {
         parent.emplyees[number] = new Employee(name, number, parent);
         registry[name] = parent.emplyees[number];
      }
   }
   function getEmplyeeBelows(name) {
      let result = [];
      result.push(...Object.values(registry).map((emp) =&gt; {
        return emp.manager == name ? [emp, ...getEmplyeeBelows(emp)] : [];
      })
      return result;
   }
   return [addEmployee, getEmplyeeBelows]
})()
addEmployee('ceo', 1, null);
addEmployee('e1', 2, 'ceo');
addEmployee("e2", 3, 'e1');
addEmployee("e3", 4, 'e1');
addEmployee("e4", 5, 'e2');
addEmployee("e5", 6, 'e2');
addEmployee("e6", 7, 'e3');

const manager = () =&gt; {

  var name = document.getElementById("txtName").value;

  eArr = getEmplyeeBelows(name);

  if (eArr.length !== 0)
    document.getElementById("ans").innerHTML = "Ans: " + eArr;
  else
    document.getElementById("ans").innerHTML = "Ans: No reportees";
}