var array = string.split(",") //转化为数组
var value = array[Math.round(Math.random()*(array.length-1))] //随机抽取一个值
alert(value)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
window.onload = function (){
var arr = ["A","B","C","D","E","F","G"]
var arr1 = []
for (var i = 0 i < arr.length i++) {
var x = arr[i]
var y = 2*i+1
var z = ""
for (var j = 0 j < y j++) {
z += x
}
arr1.push(z)
}
alert(arr1)
}
</script>
</body>
</html>
function Ad(str){......
retrue // return写错了。
}
如果希望返回aa,bb,cc的值,可以考虑把它们合并成一个数组或json,然后用return返回即可。
function Ad(str){......
var tmp = [aa,bb,cc]
return tmp
}
var sss = "qqqq|eeee|rrrrr"
var str = Ad(sss)
alert(str[0]) // aa
alert(str[1]) // bb
alert(str[2]) // cc