54. What is a pure function? Explain with the help of an example in JavaScript.
easy
A pure function is a function that always produces the same output given the same input, and has no side effects such as modifying state or interacting with the outside world. In other words, it is a function that is completely deterministic and does not have any unintended consequences.

In JavaScript, a pure function can be defined using the `const` keyword to ensure that its value cannot be changed after it has been created.
function square(x) {
  return x * x;
}

console.log(square(2)); // Output: 4
console.log(square(3)); // Output: 9
In this example, the `square` function takes a single argument `x` and returns its square value. Since the output of the function is always deterministic and does not have any side effects, it can be considered a pure function.
It's worth noting that functions that use global variables or modify state (such as arrays or objects) are not pure functions, since their behavior can depend on external factors that may change over time.