【发布时间】:2021-02-11 16:38:11
【问题描述】:
我有这个数组
switched = {"Restaurant":1,"Hotel":2,"Beauty shop":3,"Physiotherapist":4,"Dentist":5,"Bar":6,"Coffee shop":7}
还有这个对象
result = [{"Google Place URL":"http://www.restaurant.com","Business Type":"Restaurant"},{"Google Place URL":"http://www.hotel.com","Business Type":"Hotel"}]
我想验证result 的每个项目是否包含switched 的单词
另外,我已经在使用 for 单独返回每个项目
item[csvBusinessType] = Restaurant
如何验证item[csvBusinessType] 是否包含在switched 中?
我试过了
let n = switched.includes(item[csvBusinessType]);
但我得到Uncaught TypeError: switched.includes is not a function
【问题讨论】:
-
如何验证 item[csvBusinessType] 是否包含在 switch 中?
-
switched是一个对象。.includesArray的方法 -
嗯,我猜他们只是想看看
switch中的每个键是否与对应的result索引匹配 -
@TheBombSquad 也许吧,但我们不是来猜测的。现在有了编辑,这个问题就更有意义了
标签: javascript string substring