Skip to content
Permalink
7b4e193ca6
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
executable file 22 lines (18 sloc) 484 Bytes
#!/usr/bin/env node
'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')