Skip to content

Instantly share code, notes, and snippets.

Challenge: Implement Binary Search

Objective:

Write a function to perform a binary search on a sorted array of integers to find the index of a given target value. If the target is not found in the array, return -1.

Requirements:

  • The function should take two inputs: a sorted array of integers and a target integer.
  • The function must use the binary search algorithm to find the target.
  • Do not use library functions or methods for the binary search; implement the algorithm manually.
const test = () => 'this is a test';

Authentication

API Validation is performed through HTTP Basic Authentication using the CouriersPlease Account Number and Authorization Token. User Name: CouriersPlease Account Number Password: Sandbox or Production Token provided from the CouriersPlease API Developer Portal When using HTTP Basic Authentication the User Name and Password must be Base64 encoded in the header. If your CouriersPlease Account Number is W99999 and your token is ABC123456789 your Authentication Header would be “Authorization: Basic W99999:ABC123456789” before encoding it. Once encoded, it should look as follows: “Authorization: Basic Vzk5OTk5OkFCQzEyMzQ1Njc4OQ==”