Contrary to other answers here,
(Math.max(0,(y.atk-x.def))
has an extra parenthesis, at the beginning. Remove it:
Math.max(0,(y.atk-x.def))
You can indeed put an extra pair around the whole thing, as you have started to do, and as other answers appear to insist is necessary, but it isn't. It's redundant.