How to remove quotes from an array?

QuestionsQuestions8 SkillsProYour First Linux LabAug, 09 2025
0247

To remove double quotes from each string element in an array, you can use the map method along with the replace method. Here's an example:

const removeQuotesFromArray = (arr) => {
  return arr.map(str => str.replace(/"/g, ""));
};

const arrayWithQuotes = ['"Hello"', '"World"', '"JavaScript"'];
const result = removeQuotesFromArray(arrayWithQuotes);
console.log(result); // Output: ['Hello', 'World', 'JavaScript']

In this code, the removeQuotesFromArray function iterates over each element in the input array and removes double quotes from each string.

0 Comments

no data
Be the first to share your comment!