Skip to content

Commit 1f24b43

Browse files
committed
Merge branch 'coursework/sprint-1-refactor' into coursework/sprint-1-data-groups
2 parents 074cc7c + 1b6cc9b commit 1f24b43

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Sprint-1/refactor/includes.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
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+
// Loop through each element in the list using a for...of loop
5+
for (const element of list) {
6+
// If the current element matches the target, return true
67
if (element === target) {
78
return true;
89
}
910
}
11+
12+
// If the loop finishes without finding the target, return false
1013
return false;
1114
}
1215

0 commit comments

Comments
 (0)