尝试同时使用条件和 return 但它不起作用

Trying to use a conditional and return at the same time but it doesn't work

我正在尝试这样做:

(number % 2 == 0) ? return 1 : return 0; 

但是不起作用,有人知道为什么吗?

你应该这样写:

return (number % 2 == 0) ? 1 : 0;