loading...

re: Daily Challenge #142 - Parts of a Whole VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Small JavaScript answer - trying to think how I would do this with a reduce for fun: const digits = num => { const result = []; const ...
 

something like this maybe

const prepareArray = nr => String(nr).split('').map(Number);
const printPairs = arr => arr.reduce((acc, val, index) => {
  for(let i = index+1; i < arr.length; i++){
    acc.push(val+arr[i]);
  }
  return acc;
}, []);

console.log(printPairs(prepareArray(12345)))
code of conduct - report abuse