From 62e6e517d91854826f64ac20dc4d475a8885a971 Mon Sep 17 00:00:00 2001 From: "github-classroom[bot]" <66690702+github-classroom[bot]@users.noreply.github.com> Date: Thu, 12 Oct 2023 15:29:43 +0000 Subject: [PATCH 1/3] Setting up GitHub Classroom Feedback From fc72958519ffd9a4b2d47fe1a6f92f3921e3a424 Mon Sep 17 00:00:00 2001 From: "github-classroom[bot]" <66690702+github-classroom[bot]@users.noreply.github.com> Date: Thu, 12 Oct 2023 15:29:46 +0000 Subject: [PATCH 2/3] add online IDE url --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index bd38294..904e552 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![Open in Visual Studio Code](https://classroom.github.com/assets/open-in-vscode-718a45dd9cf7e7f842a935f5ebbe5719a5e09af4491e668f4dbf3b35d5cca122.svg)](https://classroom.github.com/online_ide?assignment_repo_id=12352644&assignment_repo_type=AssignmentRepo) # Where's Waldo? Return the coordinates ([row, col]) of the element that differs from the rest given a matrix (an array of arrays). From 6808549dfe6c2e9c9c6f8890928170589da5da32 Mon Sep 17 00:00:00 2001 From: Musab Sakhreyah Date: Fri, 13 Oct 2023 14:39:01 +0300 Subject: [PATCH 3/3] completed assignment --- index.js | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 3225aa4..f94302d 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,29 @@ const example = [ - ["A", "A", "A"], - ["A", "A", "A"], - ["A", "B", "A"]]; + ["O", "O", "O", "O"], + ["O", "O", "O", "O"], + ["O", "O", "O", "O"], + ["O", "O", "O", "O"], + ["P", "O", "O", "O"], + ["O", "O", "O", "O"]]; const whereIsWaldo = (matrix) => { - + let arr = [] + let notWaldo + if ((matrix[0][0] === matrix[0][1]) || (matrix[0][0] === matrix[1][0])) { + notWaldo = matrix[0][0] + } else { notWaldo = matrix[0][1] } + for (let i = 0; i < matrix.length; i++) { + for (let j = 0; j < matrix[i].length; j++) { + + switch (notWaldo) { + case matrix[i][j]: + break + default: + arr.push(i + 1) + arr.push(j + 1) + } + } + } + return arr } +console.log(whereIsWaldo(example)) \ No newline at end of file