My array is : var array1 = ['c', 'a', 'k', 'e', ' ', 'e', 'a', 't', ' ', 'I'];
Output expected is : I eat cake
How I can do that using JavaScript ?
You can use join to concate all of the chars in an array, then use split to separate them by " ". now, you can reverse that array of strings and join them once again by " ".
var s = ['c','a','k','e',' ', 'e','a','t',' ','I'];
var str = s.join("").split(" ").reverse().join(" ");
console.log(str);