I have a JavaScript object where one of the properties is an array. I want to modify that object to create an almost identical object, except that one property is a String instead.
Looks like the join method can be used to change an array to a String (e.g., console.log(elements.join('-'))).
But how do I create a new object that's identical to the old object, but with one property different (i.e., a string instead of an array)?
For example, I have this object, carOriginal:
{
"make": "Ford",
"model": "F150",
"features": [
"windows",
"seatbelts"
]
}
... and from that I want to create this object, carNew:
{
"make": "Chevy",
"model": "Tahoe",
"features": "windows,seatbelts"
}