How can I rewrite this code using a ternary operator

welcome to shbcf.ru