In python I have a Random dictionary where I use tuple as a key and each is mapped to some value.
Sample
Random_Dict = {
(4, 2): 1,
(2, 1): 3,
(2, 0): 7,
(1, 0): 8
}
example in above key: (4,2) value: 1
I am attempting to replicate this in Javascript world
This is what I came up with
const randomKeys = [[4, 2], [2, 1], [2, 0], [1, 0] ]
const randomMap = {}
randomMap[randomKeys[0]] = 1
randomMap[randomKeys[1]] = 3
randomMap[randomKeys[2]] = 7
randomMap[randomKeys[3]] = 8
randomMap[[1, 2]] = 3
I am wondering if this is the most effective way. I almost wonder if i should do something like holding two numbers in one variable so that way i can have a dictionary in JS that maps 1:1. Looking for suggestions and solutions that are better