Skip to content

jsd-genkx/js-ts-exercises-access-2d-arrays-and-functions-Among2108

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Exercise 01: Navigating the 3x3 Grid!

Instructions:

You are given a 3x3 grid with labeled cells. Your task is to simulate a journey through the grid using specific movements. Use the array to represent the grid and track your path with an array that records each move you make.

Goal: Start at cell A (position [0][0]) and move through the grid using a combination of right, down, and left movements. Make sure to track each cell you visit.

Start at A

Move right to B

Move right to C

Move down to F

Move left to E

Steps:

  1. Create a 3x3 grid using a 2D array.
  2. Use variables x and y to keep track of your current position on the grid.
  3. Use .push() to record each position visited in the moves array.
  4. Print the journey as a string separated by "→" and output the total number of moves (excluding the starting position).

Task:

Complete the provided code. (file: game.js)

// Move Right to C

// Move Down to F

// Move left to E

Bonus Task:

Create functions to complete the provided code. (file: game-fn.js)

function moveRight() {}

function moveLeft() {}

function moveUp() {}

function moveDown() {}

About

classroom-jsd11-js-ts-exercises-access-2d-arrays-and-functions-exercise-arrays-01 created by GitHub Classroom

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%