Skip to content

Instantly share code, notes, and snippets.

View stephanos7's full-sized avatar
🇨🇾

stephanos7

🇨🇾
View GitHub Profile
const findSingle = (arr) => {
let obj = {}
for(let item of arr ){
if(obj[item]{
obj[item]+= 1
}else{
obj[item] = 1
@stephanos7
stephanos7 / binary-search.js
Last active April 11, 2020 10:41
JavaScript Binary Search
const sortedArray = [1,3,5,5,7,8,11,12,14,14,15,16,16,17,17,17,17,18,19,19,19];
const bs = (arr, target) => {
let start = 0;
let end = arr.length - 1;
let tries = 1;
while(start <= end){
console.log("TRY NUMBER ", tries);