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'
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'
Share
Improve this question
edited Mar 15, 2017 at 2:38
aircraft
27k29 gold badges101 silver badges174 bronze badges
asked Mar 15, 2017 at 2:33
dpxdpx
1172 silver badges10 bronze badges
1
- don't use chrome, it's the only console that does that (well, not quite ... my console uses double quotes in the output) ... anyway ... who cares how strings a shown in a debugging tool - it makes no difference to the code – Jaromanda X Commented Mar 15, 2017 at 2:49
1 Answer
Reset to default 7If 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]);
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745439663a4627771.html
评论列表(0条)