标签:style blog color ar java for sp div log
1、给定一个单词good 要求输入 g1 o2 d1 (字母+加字母个数)
<script type="text/javascript"> var arrObj = []; var str = ‘good‘; var arr = str.split(‘‘); for (var i = 0; i < arr.length; i++) { var _j = -1; for (var j = 0; j < arrObj.length; j++) { if (arrObj[j].key == arr[i]) {//判断数组中是否已存在该字符串 _j = j; } } var num = arrObj[_j] != null ? (arrObj[_j].value + 1) : 1; if (_j != -1) { arrObj.splice(_j, 1); } arrObj.push({ key: arr[i], value: num }); }; for (var z = 0; z < arrObj.length; z++) { document.write(arrObj[z].key + arrObj[z].value); } </script>
标签:style blog color ar java for sp div log
原文地址:http://www.cnblogs.com/wzq806341010/p/4062615.html