Skip to content

Commit 5e42552

Browse files
committed
refactor includes function
1 parent b51bc9d commit 5e42552

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

Sprint-1/refactor/includes.js

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

3+
// function includes(list, target) {
4+
// for (let index = 0; index < list.length; index++) {
5+
// const element = list[index];
6+
// if (element === target) {
7+
// return true;
8+
// }
9+
// }
10+
// return false;
11+
// }
12+
313
function includes(list, target) {
4-
for (let index = 0; index < list.length; index++) {
5-
const element = list[index];
14+
for (element of list) {
615
if (element === target) {
716
return true;
817
}
918
}
1019
return false;
1120
}
12-
1321
module.exports = includes;

0 commit comments

Comments
 (0)