Slice and join array as a string - Javascript Array

Javascript examples for Array:slice

Description

Slice and join array as a string

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*from w  w w.java 2s .  co  m*/
var my = ["town", "areas", "ABC"], mySet = 1;
var userDestinationPrompt = ("Available places: " + my.slice(0, mySet).join("\n") + ".").toUpperCase();
console.log(userDestinationPrompt);
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials