In my Coffeescript code, I have created the following Javascript object:
urlSets =
a: [
'url-a.com'
'url-b.com'
'url-c.com'
]
b: [
'url-d.com'
'url-e.com'
'url-f.com'
]
c: [
'url-g.com'
]
If I have the value "url-a.com"
, how can I determine the key</cde> in <code>urlSets
that contains this URL?
I am currently using the underscore.js
library, and I thought about using _.findKey
along with _.contains
. My attempt looks like this:
_.findKey urlSets, (key) ->
return _.contains(key, "url-a.com")
However, this approach is not working as expected and results in a
TypeError: undefined is not a function
.