I was trying to solve a typescript challenge and encountered this issue Element implicitly has an 'any' type because index expression is not of type 'number'. on this line Resistors[val] I'm not sure what I'm doing wrong here. If anyone could direct me here, that'd be really helpful. Thanks in advance!
enum Resistors {
Black = 0,
Brown = 1,
Red = 2,
Orange = 3,
Yellow = 4,
Green = 5,
Blue = 6,
Violet = 7,
Grey = 8,
White = 9
}
export function decodedValue(labels : string[]) {
let valuesArr: string[] = labels.map((value: string) => {
const val: string = value.charAt(0).toUpperCase() + value.slice(1);
return Resistors[val];
});
return Number(valuesArr.join(''));
}
console.log(decodedValue(['brown', 'black']));