re: Daily Challenge #13 - Twice Linear VIEW POST

FULL DISCUSSION
 

Not sure I have well understood this one ... Am I correct with this JS function ? 🙈

const doubleLinear = (n) => {
  let u = [1];
  let i = 0;
  while(i < n) {
    u = [...u, u[i] * 2 + 1, u[i] * 3 + 1];
    u = Array.from(new Set(u))
    u.sort((a, b) => a - b);
    i++;
  }
  return u;
}

EDIT: added the line u = Array.from(new Set(u)) to get unique values !

code of conduct - report abuse