Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

npm-package-binary_search

naveenjk133ISC1.0.1

Binary Search the findout part and return index

binarysearch, algorithm

readme

binary-search-npm

A simple JavaScript utility function for performing binary search on an array. This function automatically sorts the array and returns the index of the target element if found, otherwise returns -1.

📦 Installation

npm install binary-search-npm

🔧 Usage

const binarySearch = require('binary-search-npm');

const arr = [10, 5, 3, 8, 2];
const target = 8;

const result = binarySearch(arr, target);
console.log(result); // Output: 3