function getIndexToIns(arr, num) {
// Note: using let is recommended
// instead of var
for (var val in arr) {
// The instructions say that this
// function must return a number.
// Are you returning a number?
console.log(typeof(val));
if (arr[val] >= num) {
return val;
}
}
// What are you returning if no value
// is bigger than num?
}
console.log(getIndexToIns([10, 20, 30, 40, 50], 35));
Once you look at those few issues, you’ll be pretty close to passing all tests. The only thing you’ll have left is
Return the lowest index at which a value (second argument) should be inserted into an array (first argument) once it has been sorted.