在遵循我在网上找到的一些代码示例时,我遇到了意外错误。我认为我犯了一些错误,但是与这里的其他示例相比,我找不到错误。我试图在 map 函数中包含 if 函数:
const compProfileRemoveHandler = compProfileId => {
todoList.map(profile =>(
if (profile.id !== compProfileId) {some code}
))};
有谁知道为什么我收到以下错误:“解析错误:意外的 token ”(并且“if”标记在语句下)。
非常感谢您的帮助!
最佳答案
试试这个:
const compProfileRemoveHandler = compProfileId => {
todoList.map(profile => {
if (profile.id !== compProfileId) {some code}
} )};
关于javascript - 如果在 map 函数: Getting unexpected error内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55934672/