-
Notifications
You must be signed in to change notification settings - Fork 0
todoCLI homework - week 3 #3
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
base: master
Are you sure you want to change the base?
Conversation
| }; | ||
| }; | ||
|
|
||
| function menu () {rl.question( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function menu () {rl.question(should be on separate lines
function menu() {
rl.question(|
|
||
| function menu () {rl.question( | ||
| `Welcome to ToDo CLI!\n--------------------\n(v) View ∙ (n) New ∙ (cX) Complete ∙ (dX) Delete ∙ (q) Quit\n>`, | ||
| userInput)}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should put the }; on a different line.
| function menu () {rl.question( | ||
| `Welcome to ToDo CLI!\n--------------------\n(v) View ∙ (n) New ∙ (cX) Complete ∙ (dX) Delete ∙ (q) Quit\n>`, | ||
| userInput)}; | ||
| menu(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should not be indented if you are calling this now. Otherwise it gives the impression that this should be/currently is within another function
| userInput)}; | ||
| menu(); | ||
|
|
||
| function viewList (){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When naming functions, please follow the following convention:
function functionName() {
// ...
}| menu(); | ||
| }; | ||
|
|
||
| function addNewItem (){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| menu(); | ||
| }; | ||
|
|
||
| function deleteItem (answer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| menu(); | ||
| }; | ||
|
|
||
| function quitList (){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| let myStuff = []; | ||
| //The above "myStuff" array will be storing the todo's that a user enters. | ||
| function userInput(answer){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good job naming this function so that it could be reused
| }; | ||
| }; | ||
|
|
||
| function menu () {rl.question( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job naming this function so that it could be reused
| let userInputNumber = ''; | ||
| for (let i = 1; i<answer.length; i++){ | ||
| userInputNumber += answer[i] | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This for loop essentially slices off the first character within the answer string.
Can also use
const userInputNumber = answer.slice(1);| userInputNumber += answer[i] | ||
| }; | ||
|
|
||
| myStuff[userInputNumber][0] = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should check that userInputNumber is a valid number. What happens if there are only 2 items in the list myStuff but the user types in c5? Currently this causes an error and the app quits and breaks
| userInputNumber += answer[i] | ||
| }; | ||
|
|
||
| let itemToDelete = myStuff.splice(userInputNumber,1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as #3 (comment)
Hi Max,
This is the pull request for my week-3 homework that's due on Nov 30, 2018. I will try and do the stretch from now (Monday, Nov 26, 2018) until then.
THanks,
David