Posts

Showing posts from February, 2019

Playing with array.reduce()

// I think "accumulated" is a better name than "accumulator". // This arg is the value that's been accumulated, not a // long-lasting a thing that accumulates stuff. let arr = [11,22,33] arr.reduce((accumulated, current)=>(accumulated + current)) >>66 // The first call to your function uses the first AND SECOND array elements arr.reduce((accumulated, current)=>{console.log(accumulated + ' ' + current); return 'hi'}) 11 22 hi 33 >>"hi" // ...unless you provide a second arg to Array.reduce itself. If you do, then // that second arg will be passed as accumulated on the first call of your function. // And that also means that the first call no longer consumes two elements. arr.reduce((accumulated, current)=>{console.log(accumulated + ' ' + current); return 'hi'}, 1000) 1000 11 hi 22 hi 33 >>"hi" // Using the second arg is safer. Without it, and empty array does this: ar

Start learning CSS grid here...

https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Basic_Concepts_of_Grid_Layout Shows how to create your first grid with almost no code. And then introduces syntax in logical steps. Better than what I found Googling for "tutorials". Those might be good for learning how to do specific things or digging into various topics. But if you've never looked at CSS grid and have three minutes to spare, go to the link above.