Estoy construyendo un juego de 'acorazado' CLI de nodo. Inicialmente, un usuario ingresa coordenadas que se almacenan en las variables xCoordinate y xCoordinate . Esto se maneja usando inquirer :
índice.js
import inquirer from 'inquirer' //write a function that takes in user coordinates const question1 = [ { type: "input", name: "x-coordinate", message: "Please enter the first of two coordinates", }, { type: "input", name: "y-coordinate", message: "Please enter the last coordinate", }, ]; let xCoordinate; let yCoordinate; inquirer.prompt(question1).then((answers) => { let xCoordinate = answers["x-coordinate"]; let yCoordinate = answers["y-coordinate"]; console.log( `You have entered [${xCoordinate}, ${yCoordinate}] as your coordinates` ); }); Tengo una función screenForShips que compara las coordenadas ingresadas con una matriz que contiene los "barcos" y le dice al usuario si tiene un acierto o no.
Entonces, mi pregunta es esta: en inquirer , ¿cómo se invoca la función screenForShips después de recibir información de un usuario?