Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Kenny Smith

macrumors newbie
Original poster
Dec 6, 2022

I'm working on a project that requires me to convert an array of strings to a single string, however some of the strings contain special characters and quotation marks. I realised that these characters were causing problems in the output string, so I read this scaler post on how to convert array to sting but couldn't fully comprehend it.

This is my code:
let phrases = ["Hello, world!", "She said, 'Hi!'", "It's raining."];
let combined = phrases.join("; ");
My objective was to obtain Hello, world! ; She responded, 'Hi!' ; It's raining, but the real result is Hello, world! ; 'Hi!' she exclaimed; it was pouring. The apostrophe in "It's" and the single quotation are producing issues. How should I deal with these special characters while converting the array to a string?

Your cooperation would be much appreciated. Thank you very much
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.