Merge pull request #4316 from krantzinator/fix/basic-bonfire-solutions

Add Solution For Bonfire: Where Do I Belong
This commit is contained in:
Logan Tegman
2015-11-16 10:00:06 -08:00

View File

@ -668,7 +668,9 @@
"MDNlinks": [
"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": [
"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>.');",