array join() method without a separator

Javascript

Javascript Problem Overview


var arr= ['g','o','o','d'];
var arr2 = arr.join();

Arr2 will be "g,o,o,d". I would like to get "good". I know there are a million other ways to achieve this but was curious if there was a way with join.

Javascript Solutions


Solution 1 - Javascript

Sure - just pass an empty string:

var arr2 = arr.join('');

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAdrian AdkisonView Question on Stackoverflow
Solution 1 - JavascriptShog9View Answer on Stackoverflow