Skip to content
Permalink
40f08a9f7e
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
20 lines (17 sloc) 463 Bytes
'use strict'
const readline = require('readline-sync')
const items = []
do {
var input = String(readline.question('enter command: ')).trim()
if (input.indexOf('add ') === 0) {
const space = input.indexOf(' ')
const item = input.substring(space).trim()
console.log(`adding "${item}"`)
items.push(item)
}
if (input.indexOf('list') === 0) {
for (let i=0; i< items.length; i++) {
console.log(`${i}. ${items[i]}`)
}
}
} while (input !== 'exit')