parent
a812621dc1
commit
aba76b4b35
|
@ -667,7 +667,9 @@
|
||||||
"MDNlinks": [
|
"MDNlinks": [
|
||||||
"Array.sort()"
|
"Array.sort()"
|
||||||
],
|
],
|
||||||
"solutions": [],
|
"solutions": [
|
||||||
|
"function where(arr, num) {\n arr = arr.sort(function(a, b){return a-b;});\n for (var i = 0; i < arr.length; i++) {\n if (arr[i] >= num)\n {\n return i;\n }\n }\n return arr.length;\n}"
|
||||||
|
],
|
||||||
"tests": [
|
"tests": [
|
||||||
"assert(where([10, 20, 30, 40, 50], 35) === 3, 'message: <code>where([10, 20, 30, 40, 50], 35)</code> should return <code>3</code>.');",
|
"assert(where([10, 20, 30, 40, 50], 35) === 3, 'message: <code>where([10, 20, 30, 40, 50], 35)</code> should return <code>3</code>.');",
|
||||||
"assert(where([10, 20, 30, 40, 50], 30) === 2, 'message: <code>where([10, 20, 30, 40, 50], 30)</code> should return <code>2</code>.');",
|
"assert(where([10, 20, 30, 40, 50], 30) === 2, 'message: <code>where([10, 20, 30, 40, 50], 30)</code> should return <code>2</code>.');",
|
||||||
|
|
Loading…
Reference in New Issue