Pure functions affect/change data/variables that exist only on its function scope. Pure functions are…