1 Star 0 Fork 0

FJSAY/js-homework

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
jsP60D4d2.html 604 Bytes
Copy Edit Raw Blame History
FJSAY authored 2021-04-05 14:43 . 课本作业
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>P60D4d2</title>
</head>
<body>
<script>
var arr=new Array('a','b','d','d','c','d','d');
var numarr = new Array();
var indexnum=0,num;
for (var i=0;i<arr.length;i++) {
    num = arr.indexOf('d',0); 
    if(num!=-1){    
        numarr[indexnum]=num;
        indexnum++;
    }
    arr[num]='c';
}
console.log('元素d出现的次数'+indexnum+'<br />');
console.log('所有索引下标:')
for(var i=0;i<numarr.length;i++){
    console.log(numarr[i]+',');
}
</script>
</body>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
HTML
1
https://gitee.com/fjsay0/js-homework.git
git@gitee.com:fjsay0/js-homework.git
fjsay0
js-homework
js-homework
main

Search