Convert array of characters to string
Given an array of characters, join these characters in the same order as that of the given array and create a string, using JavaScript.
Solution
To join the characters of the given array using JavaScript, call join()
method on the character array and pass an empty string for separator argument.
The join()
method returns a new string created by joining the elements of the array with given separator string.
Program
1. Given an array of characters charArray
. Join the elements of the character array to create a string output
.
const charArray = ['a', 'p', 'p', 'l' ,'e'];
var output = charArray.join("");
console.log(output);