Skip to content

Conversation

@David-Ko
Copy link
Owner

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

};
};

function menu () {rl.question(
Copy link

@maxwellgordon maxwellgordon Dec 2, 2018

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)};

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();

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 (){
Copy link

@maxwellgordon maxwellgordon Dec 2, 2018

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 (){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

menu();
};

function deleteItem (answer) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

menu();
};

function quitList (){

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){

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(

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]
};

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;

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)
Copy link

@maxwellgordon maxwellgordon Dec 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as #3 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants