Skip to content

Commit a34476b

Browse files
committed
Enumerable magic 2 solution
1 parent 8d1f9a8 commit a34476b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function any(arr, fun){
2+
for(let i = 0; i < arr.length; i++) {
3+
if(fun(arr[i])) {
4+
return true;
5+
}
6+
}
7+
return false;
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def any? list, &block
2+
for i in list
3+
val = yield i if block_given?
4+
return true if val
5+
end
6+
return false
7+
end

0 commit comments

Comments
 (0)