Reputation: 3609
I feel uncomfortable asking, but how do I convert an array of words to make a sentence ?
I keep finding the other way round.
Something like:
var a = ['hello', 'world'];
and obtain :
hello world
Upvotes: 8
Views: 8517
Reputation: 14600
This doesn't need jquery. Javascript has a very simple way of doing this with the join function:
a.join(" ");
Upvotes: 6
Reputation: 342635
Just join the elements of the array into a string using a space as a separator:
var sentence = a.join(" ");
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/join
Upvotes: 7