I have object like this :
const output =
[
{
Email: '[email protected]',
KolomB: 'Haha',
KolomC: '6',
'Kolom D': '3.000.000',
KolomE: '2 Jan 22'
},
{
Email: '[email protected]',
KolomB: 'Haha',
KolomC: '6',
'Kolom D': '3.000.000',
KolomE: '2 Jan 22'
}
]
I want to use trim()
for removing space if occurs in object keys.
I was trying with this :
let keys = Object.keys(output[0])
for (let i = 0; i < keys.length; i++) {
keys[i].trim()
}
console.log(keys)
but the result was like this :
keys = [ 'Email', 'KolomB', 'KolomC', 'Kolom D', 'KolomE' ]
The space in Kolom D
is still there.
How to do solve that, where’s my mistake for processing the data ?
Please let me know if you need more information if it’s still not enough to solve that.