Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var foo = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],
- find = [1, 10, 20],
- b = 21,
- i = find.length,
- indexOfUsingWhile = function (needle, haystack) {
- var j = haystack.length;
- while (j) {
- j -= 1;
- if (haystack[j] === needle) {
- return j;
- }
- }
- return -1;
- };
- while (i--) {
- console.log(indexOfUsingWhile(find[i], foo));
- }
- i = find.length;
- while (i--) {
- console.log(foo.indexOf(find[i]));
- }
- i = find.length;
- while (i--) {
- console.log(indexOfUsingWhile(b, foo));
- }
- i = find.length;
- while (i--) {
- console.log(foo.indexOf(b));
- }
Add Comment
Please, Sign In to add comment