Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing quotes from console log in JavaScript

I'm trying to remove the printed single quotations which occur while running the following code.

I've tried playing around with the replace(/['"]+/g, ''but I'm not getting this correctly.

var arr = ["Alpha", "Omega", "Delta"];
var symbol = "weee";
for(x=0; x<arr.length; x++){
    console.log(x,symbol,arr[x]);
}

This returns:

0 'weee' 'Alpha'

1 'weee' 'Omega'

2 'weee' 'Delta' 
like image 410
dpx Avatar asked Nov 15 '25 16:11

dpx


1 Answers

If the types of console.log parameters are different, string type will be marked by quotation marks, so you can make the parameters to a single string, just like:

 console.log(x + ' ' + symbol + ' ' +arr[x]);
like image 149
CoderLim Avatar answered Nov 17 '25 08:11

CoderLim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!