Skip to content

Commit 70627a0

Browse files
committed
refactor includes function to use for ...of loop
1 parent 4950064 commit 70627a0

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

Sprint-1/refactor/includes.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
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+
for (const element of list) {
65
if (element === target) {
76
return true;
87
}
@@ -11,3 +10,10 @@ function includes(list, target) {
1110
}
1211

1312
module.exports = includes;
13+
14+
// const array = ["a", "b", "c"];
15+
16+
// for (const element of array) {
17+
// console.log(element);
18+
// } for (variable of iterable) statement
19+

0 commit comments

Comments
 (0)