{"ScriptPreparationCode":null,"TestCases":[{"Name":"Lodash find","Code":"var a = [\u0027hello\u0027, \u0027a\u0027, \u0027bc\u0027];\r\nvar b = _.find(a, item =\u003E item === \u0027bc\u0027);","IsDeferred":false},{"Name":"Binary find","Code":"var a = [\u0027hello\u0027, \u0027a\u0027, \u0027bc\u0027];\r\nvar test = function (array, id){\r\n var startIndex = 0,\r\n stopIndex = array.length - 1,\r\n middle = Math.floor((stopIndex \u002B startIndex)/2);\r\n while(array[middle] != id \u0026\u0026 startIndex \u003C stopIndex){\r\n if (id \u003C array[middle]){\r\n stopIndex = middle - 1;\r\n } else if (id \u003E array[middle]){\r\n startIndex = middle \u002B 1;\r\n }\r\n middle = Math.floor((stopIndex \u002B startIndex)/2);\r\n }\r\n return (array[middle] != id) ? undefined : array[middle];\r\n }\r\n\r\nconsole.log(test(a, \u0027a\u0027));","IsDeferred":false}]}