trying typeof for ternary operator on canvas variable