generated from 202309-EKTA-JO-FSW/where-is-waldo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
29 lines (29 loc) · 874 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const whereIsWaldo = (arr) => {
for (let row = 0; row < arr.length; row++) {
for (let col = 0; col < arr[row].length; col++) {
if (arr[row][col] !== arr[0][0]) {
return [row + 1, col + 1];
}
}
}
return "No Waldo found";
}
console.log(whereIsWaldo([
["O", "O", "P", "O"],
["O", "O", "O", "O"],
["O", "O", "O", "O"],
["O", "O", "O", "O"],
["O", "O", "O", "O"],
["O", "O", "O", "O"]
]));
console.log(whereIsWaldo([
["c", "c", "c", "c"],
["c", "c", "c", "d"]
]));
/* itreate over outer array
compare it with other arraies if no match
itreate over inner array
compare indexes if there is no match
return out index, inner index */
//----------------------------------------------
/* write fun find the different letter and retarn (num of arr , num of index)*/