I have set up a static object:
const instruments = {
"guitar": {
tunings: ["E","A","D","G","B","E"]
},
"ukulele": {
tunings: ["G","C","E","A"]
},
"baritone": {
tunings: ["D","G","B","E"]
},
"mandolin": {
tunings: ["G","G","D","D","A","A","E","E"]
},
"bass": {
tunings: ["E","A","D","G"]
}
}
and I am trying to invoke a function using the instrument's name to fetch the appropriate 'tunings' array:
constructor(canvas : HTMLCanvasElement, tuningName : string, startFret = 0, noFrets : number) : any {
const tuningsArr = instruments[tuningName].tunings;
...
}
However, TypeScript in VSCode is showing an error. How can I correctly access the desired tunings array based on the provided string?