chrismejia / intro-to-code-js

A repo meant new JS learners help with guided topic-centered practice problems
0 stars 5 forks source link

2D Array sort of numerical values #12

Open chrismejia opened 9 months ago

chrismejia commented 9 months ago

Idea

Given a 2D array, return a 2D array where all multiples of a number are collected into subarrays. Subarrays order is from least to greatest.

Examples

Single nums

let noRepeats = [
  [1,3,4],
  [2,5]
]

// becomes...
let noRepeats = [
  [1],
  [2],
  [3],
  [4],
  [5]
]

Collecting repeats


let hasRepeats = [
  [1,6,2,8,9],
  [9,1,7,5,2]
]

// becomes...

let hasRepeats = [
  [1,1],
  [2,2],
  [5],
  [6],
  [7],
  [8],
  [9,9]
]