Skip to content

Commit 0da8e5e

Browse files
committed
includes function refactored
1 parent d56b099 commit 0da8e5e

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

Sprint-1/refactor/includes.js

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

33
function includes(list, target) {
4+
/*
45
for (let index = 0; index < list.length; index++) {
56
const element = list[index];
67
if (element === target) {
78
return true;
89
}
10+
} */
11+
for (let index of list) {
12+
if (index === target) {
13+
return true;
14+
}
915
}
1016
return false;
1117
}

0 commit comments

Comments
 (0)