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 68cee2e commit 7866c4bCopy full SHA for 7866c4b
1 file changed
Sprint-1/refactor/includes.js
@@ -1,12 +1,14 @@
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];
+ // Iterate directly over each element in the list
+ for (const element of list) {
6
+ // Return true as soon as we find a match
7
if (element === target) {
8
return true;
9
}
10
11
+ // Target was not found in the list
12
return false;
13
14
0 commit comments