One Pager Cheat Sheet
- The code snippet above is a pure function because the output is
solely dependenton the input variables andnoton any external environment, as it does not contain any variable declaredoutside ofthe function. - The
non-deterministicnature of the impure function in code snippet 2, due to external variables, makes it inherently unpredictable. - A pure function has a 1-to-1 correspondence between input and output, while an
impure functionhas a 1-to-many correspondence due to its dependence on outside variables. - True, a
pure functioncan be used to create a 1-to-many relationship between input and output. - Pure functions are
deterministicand reliable as their output is solely determined by the values of the input parameters and does not depend on global variables. - A
nested function systemis considered pure if it does not trigger anyside effectssuch as an HTTP request, mutation of data, printing to a screen, DOM manipulation or Math.random(). - The function
maxplusoneis a pure function with no side effects, as it only callsMath.max()and adds one to its result.


