• 0 Posts
  • 5 Comments
Joined 1 year ago
cake
Cake day: July 3rd, 2023

help-circle

  • In js there’s reduce. Something like

    arr.reduce((result, currentValue, currentIndex, original) => {
    if(currentIndex < original.length - 2
        && original[currentIndendex + 2] % 2 === 0 ) {
        result.push(currentValue / 2) 
    } else { 
        result.push(currentValue);
    }
    return result;
    }, []) 
    

    This would map arr and return halved values for elements for which the element two steps ahead is even. This should be available in languages where map is present. And sorry for possible typos, writing this on mobile.



  • While I think everyone can eventually learn, I know a few smart people for whom it just doesn’t click. Like, people who are great at math but get confused by simple concepts like variables and pointers. I know for me there are some topics that I just don’t get myself and unable to make a first move. Like woodworking, how would I even approach something like building a chair? I have no idea even though I’ve read and watched a few guides, just got a myriad of dumb questions instead.