我需要你身边的一些逻辑。我想计算出现的元素数量 n-在起始值和结束值之间 像
Input :Starting point in 1
end point is :10
Search :2
count :1(only 2)
Input :Starting point in 1
end point is :20
Search :2
count :3(only 2, 12 ,20)
function(var start,var end,var searchItem){
for(var start;start<=end;start++)
}
答案 0 :(得分:0)
尝试,
function search(start, end, searchItem) {
var xCnt = 0;
for (var start = 0; start <= end; start++) {
if ((start + '').indexOf(searchItem + '') >= 0) {
xCnt += 1;
}
}
return xCnt;
}