-1

I am trying to use a key (unique number) and add a letter to that key (cause you cant just do var 230 = []). so I can push the right value to the right array. How can I do that??? ):

const keys = [230, 330]

let a230 = []
let a330 = []
keys.forEach((key, value) => {
   a[key].push(value) //push value to a230...
}
)
BarakOren
  • 87
  • 6
  • 1
    Don't. Either iterate over `const arrays = [a230, a330];`, or if you really need to dynamically access the arrays using a key, put them inside a `Map` or an object instead of declaring multiple variables. – Bergi May 08 '22 at 22:06

0 Answers0