I have a JavaScript task where I have to implement a function "groupBy", which, when given an array of objects and a function, returns an object where the input objects are keyed by the result of calling the fn on each of them.
Essentially, I have to write a function, "groupBy(array, callback)", returns an object where the following is returned.
For example:
var list = [{id: "102", name: "Alice"},
{id: "205", name: "Bob", title: "Dr."},
{id: "592", name: "Clyde", …Run Code Online (Sandbox Code Playgroud) 我有一个由以下内容呈现的分组下拉菜单,
= f.select :location_id,
grouped_options_for_select(grouped_location_options,
default_location_name),
{ selected: default_location_name },
class: 'form-control'
Run Code Online (Sandbox Code Playgroud)
我希望将默认值设置为Unassigned,但上面的代码似乎没有执行我想要的操作。
有人可以给我一些线索来解决这个问题吗?
提前谢谢了!