Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add solutions to dictionary reader #42

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# assignment_node_dictionary_reader
I CAN HAS SPELLZ IN "Node"? K THNX BYE
Ann Allan
44 changes: 44 additions & 0 deletions warmup/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
function one () {
// Start listening to STDIN
process.stdin.resume()
process.stdin.setEncoding('utf8')

// Inline function to handle
// message output
var showMessage = (err) => {
console.log('State one')
console.log('Type "next" to continue')
if (err) {
console.error(err)
}
}

// Display message
showMessage()

// Handler for STDIN data
// event
var onData = (data) => {
data = data.trim()

// If user input "next"
// let's go to the next
// state
if (data === 'next') {
process.stdin.pause()
process.stdin.removeListener('data', onData)

// ----------------------------------------
// Go to next view here
// ----------------------------------------
} else {
// All other input is invalid
showMessage(`Invalid: ${data}`)
}
}
// Set the listener
process.stdin.on('data', onData)
}

// Start the app
one()