Skip to content

Commit 58dc04d

Browse files
committed
refactored the implemention of included to use for of loop instead of for loop
1 parent 7716249 commit 58dc04d

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Sprint-1/refactor/includes.js

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

3-
function includes(list, target) {
3+
/* function includes(list, target) {
44
for (let index = 0; index < list.length; index++) {
55
const element = list[index];
66
if (element === target) {
@@ -9,5 +9,16 @@ function includes(list, target) {
99
}
1010
return false;
1111
}
12+
*/
1213

13-
module.exports = includes;
14+
15+
16+
function includes(list, target){
17+
for ( let element of list){
18+
if (element === target){
19+
return true;
20+
}
21+
}
22+
return false;
23+
}
24+
module.exports = includes;

0 commit comments

Comments
 (0)