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 8323142 commit c6076edCopy full SHA for c6076ed
Sprint-1/refactor/includes.js
@@ -1,13 +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];
+ for (let element of list) {
+ // iterate through each element in the list
6
if (element === target) {
7
- return true;
+ // check if the current element matches the target
8
+ return true; // return true if a match is found and exit the function
9
}
10
- return false;
11
+ return false; // return false if no match is found after checking all elements
12
13
14
module.exports = includes;
0 commit comments