I'm trying to get the a variable from a list with a concatenation of the path, but it doesn't work.
Here is the list. I want the name in people.Tutor
and the abbrev
in base.Module
:
let parameters = {
people: {
Tutor: [{
"id": 226,
"name": "."
}]
},
base: {
Module: [{
id: 1,
abbrev: 'AMN'
}]
}
}
Here I try to concatenate the path (I made a for
loop where I search for the type, it can be people.Tutor
or base.Module
):
let type_concat = "parameters." + type;
type_concat.replace(/"/g,"");
Finally here I try to find the names in people.Tutor
or the abbrev
in base.Module
and add them into a list:
type_concat.find(function(n) {
if (n.id === constraints[l].parameters[k].id_list[m]) {
tab_username.push(n.name)
}
});
Here is the result in console :
type_concat.find is not a function