Separating mutation from calculation

In notebook:
FrontEndMasters Hardcore Functional
Created at:
Functional Programming JavaScript Fundamentals

Isolate where mutations happen

Make your functions pure and only plug in things that change at the end. 

Shows teaser function (cuts down a text by x length). In one example the teaser manipulates the dom element directly in the improved example it just receives text. 

Separates mutation from calculation. 

Again, very hard to test the function if it mutates the DOM. We have to mock out a DOM implementation.