Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bilal-ceyhun-madlibs #160

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
ayshe-ceyhun-wheres-waldo
ceyhungulbas committed May 22, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 359d0c8140c66a09bb5ad55a31c28dc55cc56cd6
59 changes: 59 additions & 0 deletions class-14-js-wheresWaldo/ayshe-ceyhun/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
let array1 = [
["d", "c", "c", "c"],
["c", "c", "c", "c"]
]

let array2 = [
["A", "A", "A"],
["A", "A", "A"],
["A", "A", "B"]
]


let array3 = [
["O", "O", "O", "O"],
["O", "O", "O", "O"],
["O", "O", "O", "O"],
["O", "O", "O", "O"],
["P", "O", "O", "O"],
["O", "O", "O", "O"]
]


function whereIsWaldo(array){
// console.log(array) -> outer
// console.log(array[0]) -> inner
for(let i = 0; i < array.length; i++){
console.log("Outer Array: ",array[i])

for(let j = 0; j < array[i].length; j++){
console.log("Inner Array: ",array[i][j])


if(array[i][j] !== array[0][0]){
console.log("Char: ", array[i][j])
let waldo = [i+1, j+1]
console.log("IF WORKED: ", waldo)
return waldo
}
else if(array[0][1] !== array[0][0] && array[0][2] !== array[0][0]){
let waldo = [i+1, j+1]
console.log("ELSE IF WORKED: ", waldo)
return waldo
}
else{
console.log("ELSE WORKED\n")
continue
}


}
}
}

console.log("ARRAY1")
console.log(whereIsWaldo(array1))
console.log("\n\nARRAY2")
console.log(whereIsWaldo(array2))
console.log("\n\nARRAY3")
console.log(whereIsWaldo(array3))