Posts

Showing posts from July, 2023

Capgemini

  // var a= 1; // console.log(a); // var a = 2; // console.log(a); // let a= 1; // console.log(a); // let a= 2; // console.log(a); //call //apply //bind // var employee1 = { firstName: "John", lastName: "Rodson" }; // var employee2 = { firstName: "Jimmy", lastName: "Baily" };  // let invite = (greeting1, greeting2) => {  console.log(greeting1 + " " + this.firstName + " " + this.lastName + ", " + greeting2  );} // invite.call(employee1, "Hello", "How are you?"); // invite.call(employee2, "Hello", "How are you?"); const data =()=>{ console.log(this)     } data() //methods // function data(){ //     console.log(this) // } https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze Lifecycle method in react child to parent why closures iffi , hoisiting Promise.race vs promise.all vs async await https://www.geeksforgeeks.org/difference-betwee...
  exception handling const arr= [9,3,1,8,12]; /**  * find the missing Numbers without built in method  * output-->[2,4,5,6,7,10,11]  *   * Approach-->  * sort the Array [1,3,8,9,12]  * iterate and check for missingNumber  * push the missing number in a new Array */ const getSortedArr =(array)=>{   for(let i=array.length;i>0;i--){     let isSwapped ;     for(let j=0; j<i-1;j++){       if(array[j]>array[j+1]){       [array[j],array[j+1]]= [array[j+1],array[j]]        isSwapped= true;       }     }     if(!isSwapped){       break;     }   }   return array } /**  * @params number[]  * @function findMissingNumber  * return number[] */ const findMissingNumber=(arr)=>{   const sorted= new Set(getSortedArr(arr));   const getMaxLength=  [...sorted].pop(); ...

Interview

 //   function checkevenodd(num){ //     return new Promise((res,rej)=>{ //     if(num%2===0){ //       res('resolved even number') //     } //     else rej('not an evne number')      //   }) //   }    // checkevenodd(2).then((res)=>console.log(res)) // .catch((err)=>console.log(err)) // (function(){ //   setTimeout(()=> console.log(1),2000); //   console.log(2); //   setTimeout(()=> console.log(3),0); //   console.log(4); // setTimeout(()=> console.log(4),2000); //     })(); // const b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; // for (let i = 0; i < 10; i++) { //   setTimeout(() => console.log(b[i]), 1000); // } // for (var i = 0; i < 10; i++) { //   setTimeout((i) => console.log(b[i]), 1000); // } const arr =[1,2,3,[[4]],5,[6],[[[[[[9],8],9]]]]] let a...
order in css inline elements position in css  z-index css grid and flex-box reverse the icon  change the order of the icons  // sayHi(); // function sayHi() { //   console.log(name); //   console.log(age); //   var name = "Lydia"; //   let age = 21; // } //myfn(); //function myfn() {   // let x = 10;   // const y = 20;   // var z = 30;   // a = 40; //} // console.log(x); // console.log(y); // console.log(z); // console.log(a); // const shape = { //   radius: 10, //   diameter() { //     return this.radius * 2; //   }, //   perimeter: () => 2 * this.radius, // }; // console.log(shape.diameter()); // console.log(shape.perimeter()); // function Person(firstName, lastName) { //   this.firstName = firstName; //   this.lastName = lastName; // } // const lydia = new Person('Lydia', 'Hallie'); // const sarah = Person('Sarah', 'Smith'); // conso...
  const arr= [1,2,3] let arr1= [...arr]; arr1.push(4); console.log(arr)  //[1,2,3] console.log(arr1) //[1,2,3,4] console.log(arr==arr1)  //false; console.log(arr===arr1) //false; print name  letter after 1 second code splitting difference between class-based components and functional component controlled uncontrolled component error boundary in case of class and functional component debouncing and throttling optimising a react app

EPAM

  https://leetcode.com/problems/longest-common-prefix/description/

Xebia Interview questions

 // const arr=[5, 7, 9, 17, 15, 11, 13, 12, 9, 15, 7, 13]; // //output==>[7,9,13...] // // for(let i=0 ;i<arr.length ;i++){    // // } // const output= arr.reduce((acc,curr)=>{    //   if(acc[curr]){ //     acc[curr] +=1; //   } //   else{ //   acc[curr]=1;      //   } //   return acc;       // },{}) // const ans=[]; // Object.entries(output).forEach(([key,value])=>{ //   if(value>1){ //   ans.push(Number(key)) // } //   }) // console.log(ans) // const arr =[11,12,41,13,71,89,90,90]; // const sortedArr =arr.sort((a,b)=>b-a); // let gratest= sortedArr[0]; // console.log(sortedArr.filter((val)=>val !==gratest)[0]) // const str="aababaabcab"; // //a6b4c1 // const output =str.split('').reduce((acc,curr)=>{ //     if(acc[curr]){ //     acc[curr] +=1;       ...

Coforge final

  //A-BC-EFG ---> GFE-CBA //Input : A-BC-EFG //G-FE-CBA const input ="A-BC-EFG" //G-FE-CBA // console.log(input.split('').reverse().join('')); //A-BC-EFG //G-FE-CBA // const reverseString =(arr)=>{ //   let postion=[] //   let reverseStr =[]; //   for(let i=arr.length-1; i>=0;i--){ //     if(arr[i] !=='-'){ //     reverseStr.push(arr[i]) //     } //     else{ //       postion.push(i)  //     } //   } //   for(let i=0; i< postion.length ;i++){    //     reverseStr.splice(postion[i],0,'-')            //   } //   return reverseStr.join('')         // } // console.log(reverseString(input.split(''))) // const arr =[1,0,2,3,0,4,11,9,7,0,15] // const ans=[]; // for(let i =0 ; i< arr.length ;i++ ){ //   if(arr[i] !==0) ...