That is too wonderful a chance to use ES6 generators to pass:
function* iterateLinkedList(start) { while (start) { yield start start = start.next } } function* filterLinkedList(iterator, filter) { for (const item of iterator) { if (filter(item)) { yield item } } } const linkedListForEach = (iterator, action) => { for (const item of iterator) { action(item) } } const iterateWagons = (start, actionFn, filterFn) => { linkedListForEach( filterLinkedList( iterateLinkedList(start), filterFn ), actionFn ) }
This may be a bit more verbose than necessary, but it is very composable.
Also, Date objects coerce to their numeric timestamps when compared and Dates initialized from ISO dates have their hours/minutes/secods/milliseconds set to zero:
const todayLastYear = new Date() todayLastYear.setFullYear(todayLastYear.getFullYear() - 1) const filterOldBreaks = wagon => new Date(wagon.lastBrakeRevision || 0) < todayLastYear
Oh man!
I was hoping to get a response from you on this task! This is wonderful!
Learned something new here! As linked list are really a new field to me.
Gonna give this another try with you example soon 👏
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
That is too wonderful a chance to use ES6 generators to pass:
This may be a bit more verbose than necessary, but it is very composable.
Also, Date objects coerce to their numeric timestamps when compared and Dates initialized from ISO dates have their hours/minutes/secods/milliseconds set to zero:
Oh man!
I was hoping to get a response from you on this task!
This is wonderful!
Learned something new here!
As linked list are really a new field to me.
Gonna give this another try with you example soon 👏