Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function find(needle, haystack) {
- if(haystack.length > 0) {
- if(needle == haystack[0]) {
- return 0;
- } else {
- var idx = find(needle, haystack.slice(1));
- if(idx !== null) {
- idx = idx + 1;
- }
- return idx;
- }
- } else {
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement