Skip to content
Advertisement

Tag: ecmascript-6

JavaScript – Promise.allSettled + Array.reduce()

Introduction Imagine this method for getting the language of a user: Now, I am trying to group the language of multiple users, performing a parallel request: Problem But my implementation is not working: How can I do for getting an output like using the Promise.allSettled combined with .reduce? Answer Your .reduce is constructing an object where each value is a

Filter Array Javascript/typescript

I have an array that needs to be filtered with specific condition If any value has -backup has suffix then it should take that and it should avoid the one without backup . Here fghij-backup has value with backup so that is the priority. If the value doesnt have backup has suffix then it should take it has priority eg:qrstuv

Get the Second Highest Date in JavaScript/ES6

I have a problem getting the second highest date in ES6. I’m using moment.js too. Its supposed to be getting the id of 3. Answer You should use custom sort function as: There is no need to use find when you are reverseing the array and getting the index 1 from it. Note: I deliberately change the order of the

Advertisement