Thread: Help Array!!!!!
View Single Post
Old 12-31-2012, 03:23 AM   PM User | #14
jmrker
Senior Coder

 
jmrker's Avatar
 
Join Date: Aug 2006
Location: FL
Posts: 2,763
Thanks: 29
Thanked 453 Times in 447 Posts
jmrker will become famous soon enough
Lightbulb

The default display of an array contents is with ',' separators.
You can alter this display with a .join() as in the following example.
Code:
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8" />
<title> Untitled </title>
<script type="text/javascript">
var arrayPrincipal = [4, 2, 13, 0, 5];
var str = '';
str += arrayPrincipal+'\n\n'+arrayPrincipal.join(',')+'\n\n';
str += arrayPrincipal.join(' ')+'\n\n'+arrayPrincipal.join(', ');
alert(str);
</script>
</head>
<body>

</body>
</html>
jmrker is offline   Reply With Quote