Hardcore Functional Programming in JavaScript Hardcore Functional Programming in JavaScript

Separating Mutation from Calculation

A function that reads DOM elements and manipulates them can be difficult to test. This is because a test case must create mock elements to feed to the function. Instead, the function could be simplified to only manipulate a piece of text. This is easier to test and leaves the mutation of the DOM to another routine.
Get Unlimited Access Now