Posts

Showing posts from February, 2024

Offset index of an array

Image
const numbers = [1,2,3,4]; const output =move(numbers,1,-1);  [2,1,3,5,4] console.log(output);  function move(array,index,offset){ } https://www.freecodecamp.org/news/swap-two-array-elements-in-javascript/   /**  * Move an element  * input ->[1,2,3,4,5];  * move(arr,index,offset)  *   * we should not modify the orignal array  *   * if not possible --> invalid  * move(input,0,-1)  *  */ const move =(arr,index,offset)=>{   const position =index+offset;      if(position>=arr.length||position<0){         return 'Invalid';   }      const clone =[...arr];   let element=clone.splice(index,1)[0];   clone.splice(position,0,element)   return clone; } const arr=[1,2,3,4,5]; console.log(move(arr,0,5))  
// const movies =[ // {title:'a',year:2018,rating:4.5}, // {title:'b',year:2018,rating:4.7}, // {title:'c',year:2018,rating:3}, // {title:'d',year:2017,rating:4.5}, // ] // //All the movies in 2018 with rating >4 // const output=movies // .filter((movie)=> movie.year===2018 && movie.rating>=4) // .sort((a,b)=>b.rating-a.rating) // .map((movie)=>movie.title) // console.log(output) //circle.radius=2 (write and read) //circle.area --> x.yxcwh (read only) // const circle={ // radius:1, // get area(){ // return Math.PI * this.radius**2 // } // } // circle.radius=12 // circle.area=1// read only can't be modified // console.log(circle.radius) // console.log(circle.area) const numbers= [1,0,-1,2,3]; const output=numbers.filter((num)=> num>=0); console.log(output) //sum(1,2,3,4) =>10; // const sum =(...args)=>{ // return args.reduce((acc,curr)=>acc+curr,0) // } // consol...

Notes

Image
26-02-24 React 19 is coming very soon. React 19 is coming with a major update. React complier They have already integrated this on Instagram. https://daily.dev/blog/react-19-everything-you-need-to-know-in-one-place

Langchan with JS

How to integrate AI with your website? Introduction to Langchan https://youtu.be/DSkyw0cXorM?si=E90M0urX14IuvGCU What is LLM --> Large Language Modal Language that we need to communicate and getting response from AI, LLM --> as it is worked on lagre

Create Content Creation

Image