Javascript examples for Array:slice
Slice and join array as a string
<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>