Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Week1 Hammed HW #24

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

Closed
wants to merge 8 commits into from
Closed

Conversation

Ahalhowidi
Copy link

my homework is index.js the other files are just exercise.

// /state
// response: the current state in a html format
// when the server starts, this should return "10"
//in this case we just show the curent state value

Choose a reason for hiding this comment

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

I love how you put the spec right in the comments. People refer to this as having the documentation "close to the code". It's a great habit to get into.

break;
// This should set the state back to 10
// I didnt want to start with error so I did the first step as reset and show the state.
case '/reset':

Choose a reason for hiding this comment

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

What will happen here if the /reset case is hit? What lines of code then get executed?

}
// this function take the state value and make some html tages to show it.
// I did some extra button to make the request url faster.
function showState(state){

Choose a reason for hiding this comment

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

I like how you pass in the state value as a parameter. This makes it slightly easier to reuse some of this code if the structure were to change.

Choose a reason for hiding this comment

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

Also, is the response object defined in this scope? Why or why not?

// response: the current state in a html format
// when the server starts, this should return "10"
//in this case we just show the curent state value
case '/state':

Choose a reason for hiding this comment

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

Your case statements should be indented further than the switch declaration.

console.log(data);
});

fs.readFile('./data1.json', 'utf-8', function(err, data) {

Choose a reason for hiding this comment

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

Head start for next week 🙃

@rts-rob rts-rob closed this Jul 7, 2017
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