Languages
[Edit]
EN

JavaScript - convert char array to string

0 points
Created by:
Krzysiek
741

In this article, we would like to show you how to convert char array to string in JavaScript.

Quick solution:

// ONLINE-RUNNER:browser;

let letters = ['A', 'B', 'C'];

let result = letters.join('');

console.log(result);  // 'ABC'

 

Practical example

In this example, we use join() method with an empty string ('') as a separator to convert the letters char array to the result string. 

// ONLINE-RUNNER:browser;

let letters = ['A', 'B', 'C'];

let result = letters.join('');

console.log(result);  // 'ABC'

join() method with various separators example:

// ONLINE-RUNNER:browser;

let letters = ['A', 'B', 'C'];

let result1 = letters.join('');
let result2 = letters.join(' ');
let result3 = letters.join('-');
let result4 = letters.join('_');

console.log(result1); // 'ABC'
console.log(result2); // 'A B C'
console.log(result3); // 'A-B-C'
console.log(result4); // 'A_B_C'
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Cross technology - convert char array to string

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join