-
Notifications
You must be signed in to change notification settings - Fork 606
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
Week1 Hammed HW #24
Conversation
// /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 |
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.
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': |
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.
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){ |
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.
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.
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.
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': |
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.
Your case
statements should be indented further than the switch
declaration.
console.log(data); | ||
}); | ||
|
||
fs.readFile('./data1.json', 'utf-8', function(err, data) { |
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.
Head start for next week 🙃
my homework is index.js the other files are just exercise.