首页 > 解决方案 > Eslint(没有未使用的表达式)

问题描述

我正在使用三元表达式来更改玩家,并且效果很好。ESLint 给了我这个错误 - https://eslint.org/docs/rules/no-unused-expressions

activePlayer === 0 ? (activePlayer = 1) : (activePlayer = 0);

你能帮我把我的代码做得更好吗?

标签: javascripteslint

解决方案


activePlayer =  activePlayer === 0 ? 1 : 0 ;

推荐阅读