数字在排序数组中出现的次数 统计一个数字在排序数组中出现的次数。 思路 用indexOf和lastIdexOf 代码 function GetNumberOfK(data, k) { // write code here if(data.indexOf(k) == -1) return 0; var count = data.lastIndexOf(k)-data.indexOf(k); return count+1; }