Skip to content

Commit 9f0d9c4

Browse files
committed
Refactor includes function to use for...of loop
1 parent 22655f0 commit 9f0d9c4

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,13 +1,12 @@
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];
4+
for (const element of list) {
65
if (element === target) {
7-
return true;
6+
return true;
87
}
98
}
10-
return false;
9+
return false;
1110
}
1211

1312
module.exports = includes;

0 commit comments

Comments
 (0)