Find Your Hat

Hi,

I’m currently doing the below project
https://www.codecademy.com/practice/projects/find-your-hat

I’m supposed to be printing the current state of the field with a .field method (task 3)
However, when I console log the arrays it returning an error.

Would be grateful if anyone could tell me where I am going wrong?

My code is below

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(''))

    }

  }

}

const newField = new Field(

  [pathCharacter, fieldCharacter, hole],

  [fieldCharacter, hole, fieldCharacter],

  [fieldCharacter, hat, fieldCharacter]

  )

  newField.print()

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.