How to convert array of words to make a sentence?

前端 未结 3 1076
情书的邮戳
情书的邮戳 2021-01-18 05:36

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:



        
相关标签:
3条回答
  • 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

    0 讨论(0)
  • 2021-01-18 06:05

    This doesn't need jquery. Javascript has a very simple way of doing this with the join function:

    a.join(" ");
    
    0 讨论(0)
  • 2021-01-18 06:06

    Do you mean something like?

    arr.join(" ");
    
    0 讨论(0)
提交回复
热议问题