Skip to content

Instantly share code, notes, and snippets.

View santhosh17s's full-sized avatar

Santhosh santhosh17s

  • Altan Calsoft Labs
  • Chennai
View GitHub Profile
@santhosh17s
santhosh17s / missingNumber.js
Last active February 21, 2018 09:30
Missing Number in Array using JS
var arr = [27,30,23,20,22,25,29,24];
function absent( arr ) {
var mia= [], min= Math.min.apply('',arr), max= Math.max.apply('',arr);
while(min<max){
if(arr.indexOf(++min)== -1) mia.push(min);
}
@santhosh17s
santhosh17s / promise.js
Last active February 22, 2018 13:45
Sleep in JS using Promises, async, wait
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
async function sleepWork(){
console.log("I'm going to sleep");
await sleep(100);
console.log("I wake up");
}
sleepWork();