<!DOCTYPE HTML>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>数组</title>
<script type="text/javascript">
//创建数组
var arr = ['*','##',"***","&&","****","##*"];
arr[7] = "**";
var myarr=[];
for(var i=0;i<arr.length;i++) {
if(arr[i]){
if(arr[i].indexOf('*') > -1) {
if(arr[i].split('*').join('').length<=0) {
myarr.push(arr[i]);
}}}}
myarr.sort();
document.write(myarr.join('<br/>'));
</script>
</head>
<body>
</body>
</html>
一颗星在数组的哪个位置,二颗星呢,三颗星呢?然后输出不就可以了吗
document.write("</br>"+arr[0]+"</br>"+arr[7]+"</br>"+arr[2]+"</br>"+arr[4])