Cleaned up where do I belong challenge
This commit is contained in:
@ -239,15 +239,13 @@
|
|||||||
"name": "Where do I belong",
|
"name": "Where do I belong",
|
||||||
"difficulty": "1.61",
|
"difficulty": "1.61",
|
||||||
"description": [
|
"description": [
|
||||||
"Return the lowest index at which a value (second argument) should be inserted into a sorted array (first argument)."
|
"Return the lowest index at which a value (second argument) should be inserted into a sorted array (first argument).",
|
||||||
|
"For example, where([1,2,3,4], 1.5) should return 1 because it is greater than 1 (0th index), but less than 2 (1st index)."
|
||||||
],
|
],
|
||||||
"challengeSeed": "function where(arr, num) {\n // Find my place in this sorted array.\r\n return num;\r\n}\n\nwhere([40, 60], 50);",
|
"challengeSeed": "function where(arr, num) {\n // Find my place in this sorted array.\r\n return num;\r\n}\n\nwhere([40, 60], 50);",
|
||||||
"tests": [
|
"tests": [
|
||||||
"var numbers = [10, 20, 30, 40, 50], num = 35;",
|
"expect(where([10, 20, 30, 40, 50], 35)).to.eql(3);",
|
||||||
"var indexForNum = where(numbers, num);",
|
"expect(where([10, 20, 30, 40, 50], 30)).to.eql(2);"
|
||||||
"assert.equal(indexForNum, 3, '35 should be inserted at index 3');",
|
|
||||||
"var indexFor30 = where(numbers, 30);",
|
|
||||||
"assert.equal(indexFor30, 2, '30 should be inserted at index 2');"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user