How could I get from the value of key:text. The problem is that txt[key].key gives an error
Element implicitly has an 'any' type because index expression is not of type 'number'.
What is the best option to get the value of key === text
const txt = [
{ key: 'topic', type: 'STRING', value: 'test' },
{ key: 'key', type: 'STRING', value: '007' },
{
key: 'text',
type: 'STRING',
value: 'I want to get this text'
}
]
Object.keys(txt).forEach(key => {
if (txt[key].key === 'text') {
console.log("Found.");
}
});
// What I also tried
Object.keys(txt).forEach((key: string | number) => {
if (txt[key].key === 'text') {
console.log("Found.");
}
});
What I want
I want to get this text
typeof this object anywhere? - Kokodoko