We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9455a47 commit 784cfd2Copy full SHA for 784cfd2
1 file changed
Sprint-1/refactor/includes.js
@@ -1,12 +1,14 @@
1
// Refactor the implementation of includes to use a for...of loop
2
3
function includes(list, target) {
4
- for (let index = 0; index < list.length; index++) {
5
- const element = list[index];
6
- if (element === target) {
+ if (!Array.isArray(list)) return false;
+
+ for (const item of list) {
7
+ if (item === target) {
8
return true;
9
}
10
11
12
return false;
13
14
0 commit comments