Этап 6
Нужна подсказка. Суть проблемы: код проходит проверку, но при запуске кода - полная беда.
Код и ошибки прилагаю)
functions.js
export const init = (term) => {
term("Welcome to the mining game! Press `G` to start! ");
term.clear();
term.hideCursor();
term.grabInput();
}
gameEngine.js
import { init } from "./functions.js"
import { handleKeyPress } from "./handlers.js";
export const startMiningGame = (term,state) => {
init(term);
term.on(`key`, handleKeyPress(term,state));
handleKeyPress(term, state);
}
solution.js
// LET'S DIG SOME GOLD!
import { startMiningGame } from "./gameEngine.js";
import {term} from "./constants.js";
import {config} from "./constants.js"
startMiningGame(term, config);
constants.js
import terminalKit from 'terminal-kit';
export const term = terminalKit.terminal;
export const config = {gold:0};
handler.js
export const handleKeyPress = (term, state) => {
return (name, matches, data) => {
if (String.fromCharCode(data.code) == "g" || String.fromCharCode(data.code) == "G"){
state.gold++;
}
}
}
Что при этом происходит в терминале:
sergeypirogov@MacBook-Air-Sergey Programming % node /Users/sergeypirogov/Documents/Programming/task250/solution.js
file:///Users/sergeypirogov/Documents/Programming/task250/functions.js:2
term(Welcome to the mining game!);
^^^^^^^
SyntaxError: missing ) after argument list
at ESMLoader.moduleStrategy (node:internal/modules/esm/translators:115:18)
file:///Users/sergeypirogov/Documents/Programming/task250/gameEngine.js:4
file:///Users/sergeypirogov/Documents/Programming/task250/gameEngine.js:4
file:///Users/sergeypirogov/Documents/Programming/task250/gameEngine.js:5
file:///Users/sergeypirogov/Documents/Programming/task250/gameEngine.js:5
file:///Users/sergeypirogov/Documents/Programming/task250/gameEngine.js:5
file:///Users/sergeypirogov/Documents/Programming/task250/gameEngine.js:5
file:///Users/sergeypirogov/Documents/Programming/task250/gameEngine.js:5
file:///Users/sergeypirogov/Documents/Programming/task250/gameEngine.js:5
file:///Users/sergeypirogov/Documents/Programming/task250/gameEngine.js:5
file:///Users/sergeypirogov/Documents/Programming/task250/gameEngine.js:5