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
how to convert a sentence into string array in java Elisavet Apostolaki String str = "This is a simple sentence"; String[] strgs = str.split(" "); Add Own solution Log in, to leave a comment
Just use the split method to convert sentences into an array of words in JavaScript. You have to use a separator which uses to indicating where each split should occur. We will use a space separator, you can use a comma or another. JavaScript split a sentence into an array of words Example
I'm having (in Java) String-Arrays like the following (more complicated, of course). Each String-Array represents one sentence (I cant change the representation):
You have to use a separator which uses to indicate where each split should occur. We will use a space separator, you can use a comma or another. HTML example code of split a string into an array of substrings, and returns the new array. Do comment if you have any doubts and suggestions on this JS array topic.
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
This doesn't need jquery. Javascript has a very simple way of doing this with the join function:
a.join(" ");
Do you mean something like?
arr.join(" ");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With