Created
September 25, 2018 10:18
-
-
Save LeWawan/e5f5661704689fafd6871c292111715d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function showMenu (menu) { | |
const args = process.argv | |
const items = menu | |
.map((item, i) => `${i}. ${item}`) | |
.join('\n') | |
console.log(` | |
=============================== | |
what you choice ? | |
=============================== | |
${items} | |
=============================== | |
you choice ${menu[args[2] - 1]} | |
=============================== | |
`) | |
} | |
module.exports = { | |
showMenu: showMenu | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const app = require('./app.js') | |
const fs = require('fs') | |
const menu = fs.readFile('./items.txt', 'utf8', (error, item) => { | |
console.log(item) | |
}) | |
// app.showMenu(menu) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment