I want to use trim() to remove the white spaces from an array but I dont want to create a new array nor do I want to use map().
I have multiple random arrays that I want to iterate through and modify the existing array.
I have arrays that look like this.
var arr = [
{
"title": "sally",
"animals": {
"type":
[
[" dog"],
[" cat "]
]
}
},
{
"title": "bob",
"animals": {
"type":
[
[" cow "],
[" bald eagle "]
]
}
}
]
but I want them to look like this:
var arr = [
{
"title": "sally",
"animals": {
"type":
[
["dog"],
["cat"]
]
}
},
{
"title": "bob",
"animals": {
"type":
[
["cow"],
["bald eagle"]
]
}
}
]
I am using the split() function which is causing the values to add a space.