diff --git a/Sprint-1/refactor/includes.js b/Sprint-1/refactor/includes.js index 29dad81f0..145603948 100644 --- a/Sprint-1/refactor/includes.js +++ b/Sprint-1/refactor/includes.js @@ -1,12 +1,15 @@ // Refactor the implementation of includes to use a for...of loop function includes(list, target) { - for (let index = 0; index < list.length; index++) { - const element = list[index]; + // Loop through each element in the list using a for...of loop + for (const element of list) { + // If the current element matches the target, return true if (element === target) { return true; } } + + // If the loop finishes without finding the target, return false return false; }