Skip to content

Commit b360d0d

Browse files
committed
use for of loop to refactor includes function. all tests pass after refactoring
1 parent 9451483 commit b360d0d

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

‎Sprint-1/refactor/includes.js‎

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

33
function includes(list, target) {
4-
for (let index = 0; index < list.length; index++) {
5-
const element = list[index];
6-
if (element === target) {
4+
for (item of list) {
5+
if (target === item)
76
return true;
87
}
9-
}
8+
109
return false;
1110
}
1211

0 commit comments

Comments
 (0)