constants.js

import terminalKit from 'terminal-kit';
export const term = terminalKit.terminal;

functions.js

export const init = (term) => {
    return 'Welcome to the mining game! Press "G" to start!'
} 

gameEngine.js

import {init} from './functions.js'


export const startMiningGame = (term) => {
    init()
}

solution.js

import {startMiningGame} from './gameEngine.js'
import {term} from './constants.js'
import {init} from './functions.js'

term(`Welcome to the mining game! Press 'G' to start!`)

Text "Welcome to the mining game! Press 'G' to start!" is successfully prints on the screen, but still i have the following issue:
4. init should accept a single parameter and use it to print the string Welcome to the mining game! Press 'G' to start!

  • Coderslang_Master replied to this.
  • robertw8 Here's how you should start the came.

    startMiningGame(term)

    The init function should be called from within startMiningGame

    Then, you should carry on with the term param

    init(term);

    In init you should use term to print the correct message to the screen.

    Remove everything that you don't need.

    robertw8 thank you for the perfectly formatted question.

    Let's break the problem apart:

    • The hint suggests that init should accept a single parameter, but at the moment you're not passing anything into it.
    • Second part of the hint says use it to print the string Welcome to the mining game! Press 'G' to start!. So you should use that incoming parameter and print out the message not from solution directly, but from the function init.

    The only call that you need to make from the solution would be startMiningGame(term). You can also remove some unused imports.

      Coderslang_Master

      I've remade the code with your hints, also tried many new solutions but still i have the same issue.

      constants.js

      import terminalKit from 'terminal-kit';
      export const term = terminalKit.terminal

      functions.js

      export const init = (term) => {
          return "Welcome to the mining game!"
      }

      gameEngine.js

      import {init} from './functions.js'
      
      export const startMiningGame = (term) => {
          init("Press 'G' to start!")
      }

      solution.js

      import {startMiningGame} from './gameEngine.js'
      import {term} from './constants.js'
      import {init} from './functions.js'
      
      startMiningGame(term(init(term)))

      P.S. Also i've tried to submit this task with only startMiningGame(term), but had an issue term is not a function.

        robertw8 Here's how you should start the came.

        startMiningGame(term)

        The init function should be called from within startMiningGame

        Then, you should carry on with the term param

        init(term);

        In init you should use term to print the correct message to the screen.

        Remove everything that you don't need.

          Write a Reply...