We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 96d077b commit 1b6cc9bCopy full SHA for 1b6cc9b
1 file changed
Sprint-1/refactor/includes.js
@@ -1,12 +1,15 @@
1
// Refactor the implementation of includes to use a for...of loop
2
3
function includes(list, target) {
4
- for (let index = 0; index < list.length; index++) {
5
- const element = list[index];
+ // Loop through each element in the list using a for...of loop
+ for (const element of list) {
6
+ // If the current element matches the target, return true
7
if (element === target) {
8
return true;
9
}
10
11
+
12
+ // If the loop finishes without finding the target, return false
13
return false;
14
15
0 commit comments