isNull function checks if element is null or undefined to prevent usage of || in if statements