Just getting back to coding and doing some practice on some fun code I came across from a friend.
I am using inquirer to ask the user what attack they would like to use. I then want to pass that information into another function.
I am having trouble finding a way to take the option from the array that the user chooses, and use it outside of the attackPrompt function.
Almost anything helps. Thanks.
let attacks = [
"Slap",
"Bite",
"Kick",
]
function attackPrompt() {
let attackChoice = [{
name:"attack",
type:"list",
message:"Choose your attack.",
choices: attacks
}]
inquirer.prompt(attackChoice).then((answer) => {
attackChosen(attackOption);
console.log("MY STRING HERE", answer.attack)
//trying to make a function where I can pass the information to another maybe?
function attackChosen() {
let optionFromChooseAttack = answer
// console.log("I PUT THIS STRING HERE", optionFromChooseAttack)
}
})
}
attackPrompt();