I have following sample code:
var x = [
{input1: "aaa"},
{input2: "bbb"},
{input444: "ddd"},
{input55: "eee"}
{input3: "ccc"},
]
I am trying to get values of props which if exists in the object something like
x.forEach((item, index) => {
console.log(item.[`input${index}`]);
})
So for above sample code : I want output to be ["aaa", "bbb", "ccc"]
I know the first part of the property (which in this example is 'input') and second part will be index only
Is it possible to know the values using Optional chaining? What I am missing?