Made trimNull a reusable function with any array