Finders Keepers
来源:互联网 发布:存款数据 编辑:程序博客网 时间:2024/06/05 07:29
题目
写一个 function,它遍历数组 arr,并返回数组中第一个满足 func 返回值的元素。举个例子,如果 arr 为 [1, 2, 3],func 为 function(num) {return num === 2; },那么 find 的返回值应为 2
要求
find([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; }) 应该返回 8。find([1, 3, 5, 9], function(num) { return num % 2 === 0; }) 应该返回 undefined。
代码
function find(arr, func) { var num = 0; num = arr.filter(func)[0]; return num;}find([1, 2, 3, 4], function(num){ return num % 2 === 0; });
阅读全文
0 0
- Finders Keepers
- watij/finder/Finders classnotfoundexception
- Ruby学习笔记(23)_Capybara Finders
- uva 10163 Storage Keepers
- UVA 10163 Storage Keepers
- UVA 10163 Storage Keepers
- UVA - 10163 Storage Keepers
- uva 10163 Storage Keepers
- UVA 10163 - Storage Keepers
- uva 10163 Storage Keepers
- UVA - 10163 Storage Keepers
- UVa 10163 Storage Keepers
- UVA - 10163 Storage Keepers
- UVA 10163 Storage Keepers
- Storage Keepers UVA
- Storage Keepers UVA
- Storage Keepers UVA
- uva_10163 - Storage Keepers ( 普通DP )
- Python代码实现双色球原理
- Spring transaction事务之roll back回滚: rollback-for
- 虚拟机安装centos7迷你版
- 网址是否区分大小写
- chap02-java程序设计环境-卷一
- Finders Keepers
- spark初探,官方文档
- java.lang.ClassNotFoundException: org/apache/xerces/parsers/SAXParser
- 解决The JAVA_HOME environment variable is not defined correctly
- Spring中jdbcTemplate的用法实例(一)
- ajax 如何用then 链式操作 实现异步先后执行顺序
- Learning k for kNN Classification--论文笔记
- df -h 无响应
- USB Camera运行ORBSLAM2