Skip to content

Commit 4e0a556

Browse files
Alex JamshidiAlex Jamshidi
authored andcommitted
changed includes.js code to add for...of loop
1 parent ee7e6d4 commit 4e0a556

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

Sprint-1/refactor/includes.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
// Refactor the implementation of includes to use a for...of loop
22

33
function includes(list, target) {
4+
for (item of list) {if (item === target) {return true;}}
5+
return false;
6+
}
7+
8+
module.exports = includes;
9+
10+
11+
/* Old code:
12+
413
for (let index = 0; index < list.length; index++) {
514
const element = list[index];
615
if (element === target) {
716
return true;
817
}
918
}
1019
return false;
11-
}
12-
13-
module.exports = includes;
20+
*/

0 commit comments

Comments
 (0)