I have an array like this:
const allData =
[
['Alex ','foo@email',' ',],
[' ','goo@gmail, '232-333-2222'],
]
I want to trim all values within the array so that for example 'Alex '
becomes 'Alex'
.
I have tried these solutions:
for (let data of allData.entries()) {
for (let content of data) {
content.trim();
}
}
allData.forEach((data) => {
data.forEach((content) => {
content.trim();
});
});
allData.map((data, index) => {
return data.map((content) => content.trim());
});
I have tried content = content.trim();
for all of them as well.
But even though it does trim the value it won't save the modified value in the array.
What am I missing? I want allData
to contain the trimmed values.