// getGeocode = (callBack) =>{
// const data = {
// lat:0,
// long:0
// }
// callBack(data);
// }
// const funcA = function(data){
// setTimeout(()=>{
// console.log(data,"A");
// fnB(data)
// });
// }
// const funcB = function(data){
// setTimeout(()=>{
// console.log(data,"B")
// fnC(data)
// });
// };
// const funcC = function(data){
// setTimeout(()=>{
// console.log(data,"B")
// });
// };
// getGeocode(function(data){
// setTimeout(()=>{
// console.log(data,"A");
// function fnB(data){
// setTimeout(()=>{
// console.log(data,"B")
// function fnC(data){
// setTimeout(()=>{
// console.log(data,"C")
// },1000);
// }
// fnC(data);
// },1000);
// }
// fnB(data);
// },1000);
// });
var p1 = function(data){
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log(data+' one')
resolve(data+' one')
});
});
}
var p2 = function(data){
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log(data+' two');
return resolve(data+' two')
});
})
};
var p3 = function(data){
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log(data+' three');
return resolve(data+' three')
});
});
};
var p4 = function(data) {
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log(data+' four');
return resolve(data+' four')
});
});
}
// // var p5 = new Promise((resolve, reject) => {
// // reject(new Error('reject'));
// // });
// p1('start').then(res=>p2(res))
// .then(res2=>p3(res2))
// .then(res3=>p4(res3));
// const foo = async() => {
// const result = await p1('start');
// const newResult = await p2(result);
// const newResult2 = await p3(newResult);
// const finalResult = await p4(newResult2);
// }
// foo()
var p1 = (data) =>p2((data)=> p3((data)));
p1('test');
// function myFunction(p1,callback){
// let x = 2;
// console.log('2 before',x);
// callback(x,p1);
// }
// let cb = function(x,y){
// switch(y){
// case 'increment':
// x++;
// console.log('2 after',x);
// break;
// case 'decrement':
// x--;
// console.log('2 after',x);
// break;
// }
// }
// myFunction('increment',cb);
// myFunction('decrement',cb);
// let result = 0;
// function createFunc(p){
// return {
// add:function(q){
// result = result+ q;
// console.log('add',result);
// return this;
// },
// sub:function(q){
// result = result-q;
// console.log('sub',result);
// return this;
// },
// value: function(){
// return result;
// },
// }
// }
// let c = createFunc(10);
// console.log(c.add(10).sub(5).value());
// var arrayOfInt = [2, 5, 1, 4, 9, 6, 3, 7];
// var upperBound = 9;
// var lowerBound = 1;
// console.log(findMissingNumber(arrayOfInt, upperBound, lowerBound)); // 8
// function findMissingNumber(arrayOfInt, upperBound, lowerBound) {
// // Iterate through array to find the sum of the numbers
// var sumOfIntegers = 0;
// for (var i = 0; i < arrayOfInt.length; i++) {
// sumOfIntegers += arrayOfInt[i];
// }
// // Find theoretical sum of the consecutive numbers
// // variation of Gauss Sum.
// // Formula: [(N * (N + 1)) / 2] - [(M * (M - 1)) / 2];
// // N is the upper bound and M is the lower bound
// upperLimitSum = (upperBound * (upperBound + 1)) / 2;
// lowerLimitSum = (lowerBound * (lowerBound - 1)) / 2;
// theoreticalSum = upperLimitSum - lowerLimitSum;
// return theoreticalSum - sumOfIntegers;
// }
// var inputStack = []; // First stack
// var outputStack = []; // Second stack
// // For enqueue, just push the item into the first stack
// function enqueue(stackInput, item) {
// return stackInput.push(item);
// }
// function dequeue(stackInput, stackOutput) {
// // Reverse the stack such that the first element of the output stack is the
// // last element of the input stack. After that, pop the top of the output to
// // get the first element that was ever pushed into the input stack
// if (stackOutput.length <= 0) {
// while (stackInput.length > 0) {
// var elementToOutput = stackInput.pop();
// stackOutput.push(elementToOutput);
// }
// }
// return stackOutput.pop();
// }
// enqueue(inputStack,1);
// console.log(inputStack,outputStack)
// enqueue(inputStack,2);
// console.log(inputStack,outputStack)
// enqueue(inputStack,3);
// console.log(inputStack,outputStack)
// enqueue(inputStack,4);
// console.log(inputStack,outputStack)
// dequeue(inputStack,outputStack);
// console.log(inputStack,outputStack)
// var inputStack = []; // First stack
// var outputStack = []; // Second stack
// function enqueue(stackInput,N){
// return stackInput.push(N);
// }
// function dequeue(stackInput,stackOutput){
// if(stackOutput.length <= 0){
// while(stackInput.length > 0){
// let x = stackInput.pop();
// stackOutput.push(x);
// }
// }
// return stackOutput.pop();
// }
// console.log(enqueue(inputStack,1));
// console.log(enqueue(inputStack,2));
// console.log(enqueue(inputStack,3));
// console.log(enqueue(inputStack,4));
// console.log(dequeue(inputStack,outputStack));
// console.log(dequeue(inputStack,outputStack));
// //console.log(inputStack,outputStack)
// console.log(["",0, -0,NaN,null, undefined,false]);
// function check(p){
// let res = [];
// res = p.map((el)=> el ? true:false);
// return res;
// }
// let x = check(["",0, -0,NaN,null, undefined,false]);
// console.log(x)
//Thease will make the boolean values as false
//Any values not in this will become true some examples are
//console.log("hello", 42, true ,[ ], [ 1, "2", 3 ] ,(arrays) { }, { a: 42 } (objects) function foo() { .. } (functions));1
let number = 16;
// let res = number.toString(2)
// console.log(res);
// function decToBinary(n) {
// let binaryNum = [];
// // counter for binary array
// while (n > 0) {
// // storing remainder in binary array
// binaryNum.push(n % 2);
// n = Math.floor(n / 2);
// }
// // reverse array to get binary array
// return binaryNum.reverse().join("");
// }
// console.log(decToBinary(number));
// // using recursion
// function decToBinary(decimalNum) {
// if (decimalNum == 0) return 0;
// else {
// console.log("("+decimalNum+" % 2) + 10 * decToBinary(parseInt("+decimalNum+" / 2))");
// return (decimalNum % 2) + 10 * decToBinary(parseInt(decimalNum / 2));
// }
// }
// let decimalNum = 13;
// console.log(decToBinary(decimalNum));
// function* groceriesGenerator(){
// yield 'Eggs'
// yield 'Tomatoes'
// yield 'Milk'
// return 'Paper Bag'
// }
// const groceries = groceriesGenerator()
// console.log(groceries.next()) // [1]
// console.log(groceries.next()) // [2]
// console.log(groceries.next()) // [3]
// console.log(groceries.next()) // [4]
// function checkAnagrams(str1, str2) {
// if (str1.length !== str2.length) return false;
// let s1 = str1.split("").sort().join("");
// let s2 = str2.split("").sort().join("");
// return s1 !== s2 ? false : true;
// }
// console.log(checkAnagrams("inida", "aidni"));
// function arryIntersect(array1, array2) {
// return array1.filter(function (val) {
// return array2.indexOf(val) !== -1;
// });
// }
// console.log(arryIntersect([1,'2',3,4],['2',3,5,6])) // true
// function maxTripletProduct(arr) {
// let n = arr.length;
// // If size is less than 3, no triplet exists
// if (n < 3) return false;
// // Sort array in ascending
// arr.sort((a, b) => a - b);
// // max between (+ve: last three ele)
// // and (-ev: 1st 2nd and last ele)
// return Math.max(arr[0] * arr[1] * arr[n - 1],
// arr[n - 1] * arr[n - 2] * arr[n - 3]);
// }
// let arr = [-20, -10, -92, -3, 5, 6, -20, 90];
// console.log(maxTripletProduct(arr));
// function checkPalindrome(str1, str2) {
// if (str1.length != str2.length) return false;
// for (i = 0, j = str2.length - 1; i < str1.length; i++, j--) {
// if (str1[i] !== str2[j]) return false;
// }
// return true;
// }
// function checkAnagrams(str1, str2) {
// if (str1.length !== str2.length) return false;
// let s1 = str1.split("").sort().join("");
// let s2 = str2.split("").sort().join("");
// return s1 !== s2 ? false : true;
// }
// console.log(checkAnagrams("india", "aindi")); //true
// console.log(checkPalindrome("India", "aidni")); //false
// console.log('India'.toLowerCase());
// Create a function to multiply three items
function multiply(a, b, c) {
return a * b * c
}
let numbers = [1,2,3];
console.log(multiply(1,2,3,));
console.log(multiply(...numbers));
console.log(multiply.apply(null,numbers));