S
S
Shakir Darion2019-10-23 16:02:21
JavaScript
Shakir Darion, 2019-10-23 16:02:21

Undefined typescript object properties?

this is my code

const channel = {},
arr = [string,string,string];
for(let i = 0;i < arr.length;i++ ){
    channel[arr[i]] = "Amo" //equal string value
}

The array contains only string values. example ["a","b","c","n"]. How can I write this code in typescript?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tosha4encko, 2019-10-23
@shakiriker

const channel: {[key: string]: string} = {}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question