Skip to content Skip to sidebar Skip to footer

How To Replace Single Quotes Instead Of Double Quotes In Array Of Javascript?

I have an array of string values with double quotes all i want is convert the array string value with single quotes. Var arr=['abc123','cde345','ijk789']; var test=[] for(var i=0;

Solution 1:

You could map the items with single quotes for a list and join it with comma.

var array = ["abc123", "cde345", "ijk789"],
    list = array.map(s =>`'${s}'`).join(', ');

console.log(`select * from tableName where id in (${list})`);

Post a Comment for "How To Replace Single Quotes Instead Of Double Quotes In Array Of Javascript?"