Skip to content

Commit 6cdb275

Browse files
committed
Includes Excercise
1 parent b647f3a commit 6cdb275

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

Sprint-1/refactor/includes.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
// Refactor the implementation of includes to use a for...of loop
22

3-
function includes(list, target) {
4-
for (let index = 0; index < list.length; index++) {
5-
const element = list[index];
6-
if (element === target) {
7-
return true;
8-
}
3+
// function includes(list, target) {
4+
// for (let index = 0; index < list.length; index++) {
5+
// const element = list[index];
6+
// if (element === target) {
7+
// return true;
8+
// }
9+
// }
10+
// return false;
11+
// }
12+
13+
14+
function includes(list,target){
15+
for (let value of list) {
16+
if (value === target) {
17+
return true;
918
}
10-
return false;
1119
}
20+
return false;
21+
};
1222

1323
module.exports = includes;

0 commit comments

Comments
 (0)