about | help | code help+videos | done | prefs |
indexOf
Given an array and a key, return the index of the first occurrence of the key in the array, or return -1 if the key is not found in the array. This is the standard linear search algorithm, but solved recursively. Note: You should solve this recursively (no loops). You will need a recursive helper method that takes an array and a key and an index as parameters. indexOf([3, 7, 5], 3) → 0 indexOf([3, 8, 2, 2], 2) → 2 indexOf([4, 8, 15, 16, 23, 42], 99) → -1 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 300
Copyright Nick Parlante 2017 - privacy