use ternary in `for` loop