add solution for Where Do I Belong

Update basic-bonfires.json
pull/4316/head
krantzinator 2015-11-11 21:57:45 -05:00 committed by Rachel Krantz
parent a812621dc1
commit aba76b4b35
1 changed files with 3 additions and 1 deletions

View File

@ -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>.');",