Find Your Hat Challenge Project

I’m working on the Find Your Hat challenge project: https://www.codecademy.com/practice/projects/find-your-hat

And I’m stuck on Step 3; I have tried using join("") to print out the arrays as a string, while this removes the comma between the arrays, there are still commas between the elements in the individual arrays.

This is my code:

const hat = '^';
const hole = 'O';
const fieldCharacter = '░';
const pathCharacter = '*';

class Field {
  constructor(field) {
      this._field = field;
   }
   print(field) {
  console.log(this._field.join(""));
   }   
}

class NewField extends Field {
    constructor(field) {
        super(field);
    }
}

const myField = new NewField([[pathCharacter, fieldCharacter, hole], [fieldCharacter, hole, hole], [fieldCharacter, hat, fieldCharacter]]);


myField.print();

The output is:

"*,░,O░,O,O░,^,░"

Hey! This is where I am at so far @ruby9951660504.
#teamworkMakesTheDreamwork

const prompt = require('prompt-sync')({sigint: true});

const hat = '^';
const hole = 'O';
const fieldCharacter = '░';
const pathCharacter = '*';

class Field {
  constructor (fieldArray) {
    this._field = fieldArray;
  }

  get field() {
    return this._field;
  }

  print(){
    for (let i = 0; i < 3; i ++){
    console.log(this._field[i].join(''))
  }
  }
}

const myField = new Field([
  [pathCharacter, fieldCharacter, hole],
  [fieldCharacter, hole, fieldCharacter],
  [fieldCharacter, hat, fieldCharacter],
]);

myField.print();

the output looks like this
Screen Shot 2020-05-10 at 2.51.14 PM

I’m not sure why this is a current project for my progress though. I am working through the front end react program. I am 48%. I have never worked in node, nor have i dealt with user input or saving data states. Not that I dont want to be here and be able to do this, but this seems further along than the codeAcademy tutorials have taken me thus far. any admin input here? Am i in the wrong project?

Thanks for sharing your code :grinning:

My steps 1-3 are complete, but I am stuck on even getting started with Step 4.

So far my code is:

const prompt = require('prompt-sync')({sigint: true});


const hat = '^';
const hole = 'O';
const fieldCharacter = '░';
const pathCharacter = '*';


class Field {
  constructor(field) {
      this._field = field;
   }
   print() {
     for (let i= 0; i < 3; i++)
  console.log(this._field[i].join(""));
   }   
}

class NewField extends Field {
    constructor(field) {
        super(field);
    }
    hatLocation() {
x = Math.floor(Math.random() * fieldW);
y = Math.floor(Math.random() * fieldH);
    }
};

const myField = new NewField([[pathCharacter, fieldCharacter, hole], [fieldCharacter, hole, hole], [fieldCharacter, hat, fieldCharacter]]);


myField.print();

Next, my best guess is that we need to get user input so we know where to move the pathCharacter. I think it should follow something along the lines of this, but I have no idea how to build it out further:

//Method to get user input and update the pathCharacter (*) 

let userInput = prompt("Which way would you like to move?");

    //Use keyboard events to determine which way the user moves and update location  

const moveUser = (prompt) => {
 userMove.onArrowDown = function () {
  //pathCharacter moves down
  
}
userMove.onArrowLeft = function () {
  //pathCharacter moves left

}
userMove.onArrowRight = function () {
 //pathCharacter moves right
}
userMove.onArrowUp = function () {
 //pathCharacter moves up 
}
};