Pure Functions A pure function in Javascript is one that given the same input will always return the same output…