rmurphey / js-assessment

A test-driven approach to assessing JS skills
5.15k stars 2.05k forks source link

One more edge case for indexOf #205

Open SergeyVoloshchuk opened 7 years ago

SergeyVoloshchuk commented 7 years ago
function indexOf  (arr, item) {
    var index = null;
    for (var i = 0; i < arr.length; i++) {
      if (arr[i] === item) {
        index = i;
        break;
      }
    }
    if (index) {
      return index;
    }
    return -1;
  }