I have Array Array1
Array1=[
"fish.jpg",
"animal.jpg",
"tree.jpg"]
I want to store them in my excel but problem is they are coming with square brackets and double quotes
["Fish.jpg","animal.jpg","tree.jpg"]
So my excel cell look like this
name | data | owner
jpg | ["Fish.jpg","animal.jpg","tree.jpg"] | Vikas
I want them as single output only they separated by comma(,) as i want to store them in single cell in excel
fish.jpg, animal.jpg,tree.jpg
so my excel will look like this
let removedData= Array1.replaceAll("[""]");
but got no success
name | data | owner
jpg | fish.jpg, animal.jpg,tree.jpg | Vikas
Note here name,data,owner are one cell title
It's not that arrays of strings have []
or "
in them (they don't), it's that something is converting them to string by using JSON.stringify
or similar. (If it were just using toString
, there wouldn't be "
in the result.)
Instead, convert to string on purpose. Arrays have a join
method to join all of their entries (converted to string if necessary) into a single string using the delimiter you provide:
value = yourArray.join(", ");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.