Skip to content

Commit 02e7fdc

Browse files
Refactor includes function to use for...of loop for improved readability
1 parent 55d7528 commit 02e7fdc

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 @@
1-
// Refactor the implementation of includes to use a for...of loop
1+
// Refactored implementation of includes using 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) {
76
return true;
87
}
98
}
109
return false;
1110
}
1211

13-
module.exports = includes;
12+
module.exports = includes;

0 commit comments

Comments
 (0)