Find Your Hat - I don't understand how to use the terminal

Link: https://www.codecademy.com/practice/projects/find-your-hat

This doesn’t run like the other projects (ctrl + enter). I know I need to use ‘node main.js’ to run it. I got a syntax error on my array I declared. However, even after I comment out the array, I still get the syntax error. I have commented out the entire code except 'console.log(‘hello’) and I am still getting the syntax error. Is this a problem on Codecademy’s end or am not using the terminal right?

Code:

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

const name = prompt('What is your name?');

console.log(`Hey there ${name}`);

const hat = '^';

const hole = 'O';

const fieldCharacter = '░';

const pathCharacter = '*';

class Field {

  constructor (myField) {

    this._field = myField;

  }

  printTime () {

    console.log(this._field);

  }

  

}

const myField = [[░,░,░,░,░,░,░,░], [░,░,░,░,░,░,░,░], [░,░,░,░,░,░,░,░], [░,░,░,░,░,░,░,░], [░,░,░,░,░,░,░,░], [░,░,░,░,░,░,░,░], [░,░,░,░,░,░,░,░], [░,░,░,░,░,░,░,░], [░,░,░,░,░,░,░,░], [░,░,░,░,░,░,░,░]];

//const currentField = new Field(myField);

//currentField.printTime();

console.log(myField);*/

console.log('hello');

Terminal with Error:

$ node main.js
/home/ccuser/workspace/find-your-hat/main.js:25
const myField = [[░,░,░,░,░,░,░,░], [░,░,░,░,░,░,░,░], [░,░,░,░,░,░,░,░], [░,░,░,░,░,░,░,░], [░,░,░,░,░,░,░,░], [░,░,░,░,░,░,░,░], [░,░,░,░,░,░,░,░], [░,░,░,░,░,░,░,░], [░,░,░,░,░,░,░,░], [░,░,░,░,░,░,░,░]];
                  ^
SyntaxError: Invalid or unexpected token
    at createScript (vm.js:53:10)
    at Object.runInThisContext (vm.js:95:10)
    at Module._compile (module.js:543:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:427:7)
    at startup (bootstrap_node.js:151:9)

Notice the difference between this:

and this:

1 Like

Ah yes, there is the syntax error. But I think my main concern is, why is the syntax error still showing up if i commented the code out?

My best guess would be that perhaps you didn’t click Save before re-entering the node main.js command.

1 Like

My god, you’re a genius. Thanks. haha

2 Likes