loading...

re: Daily Challenge #17 - Double Trouble VIEW POST

FULL DISCUSSION
 

Not a better solution compared to @alvaromontoro but here is mine in js


const doubleTrouble = (queue, nthCola) => {
  let person;
  for(let index = 0; index < nthCola; index++) {
    if(index+1 === nthCola) {
      person = queue[0];
      break;
    }
    queue = queue.flat(queue.push(Array(2).fill(queue.shift())));
  }
  return person;
};

code of conduct - report abuse