body {
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: monospace;
  font-size: 2rem;
}
View Compiled
function getPerfect(from, to) {
  let res = [];
  for (let i = from; i < to; i++) {
    sum = 0;
    for (let j = 1; j <= i/2; j++) {
      if (i % j === 0) sum += j;
    }
    if (i === sum) res.push(i);
  }
  return res;
}

document.body.innerText = getPerfect(1, 800);

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.