求问!web前端 2016阿里应届生编程题 js题目
原题目: 请实现find函数,使下列的代码调用正确。
约定: title数据类型为String
userId为主键,数据类型为Number
```
var data = [ {userId: 8, title: 'title1'}, {userId: 11, title:
'other'}, {userId: 15, title: null}, {userId: 19, title: 'title2'}
];
var find = function(origin){ //your code are here... }
//查找data中,符合条件的数据,并进行排序
测试用例:
var result = find(data).where({"title":
/\d$/}).orderBy('userId', 'desc'); console.log(result); // [{
userId: 19, title: 'title2'}, { userId: 8, title: 'title1' }];
下面是我的写法:
这个写法输出正确。感觉题目的意思不是这样子。请教各位大神,有更好的写法吗?