Is there a way to make an object detect if its value is equal to another object's key and then retrieve it?
Let's consider the following object named:
AnswerString
let AnswerString ={
0: "B",
1: "x"
}
and the answers are in different objects, but for simplicity let's focus on just one object called M2060
Let's define M2060 as:
var M2060 = {
"B" : [
"v-40 a20,10 0 0 1 0,20 a20,10 0 0 1 0,20",
],
"x" : [
"l20,-20 l-10,10 l10,10 l-10,-10 l-10,-10"
],
}
The name M2060 is based on it being the starting move to function for the SVG 'd' attribute. With that, how can I make 0 and 1 equal to the values in AnswerString?
AnswerString = {
0: "v-40 a20,10 0 0 1 0,20 a20,10 0 0 1 0,20",
1: "l20,-20 l-10,10 l10,10 l-10,-10 l-10,-10"
}
Should I create another object with these values and if so, how can I do that? I have been attempting:
if (M2060[answersString]) {
let solution1 = M2060[answersString]);
}
However, it seems that this approach is not working. EDIT: It seems I was missing .Entries and map methods.