Lesson 1 4 - #6
Conversation
esthicodes
left a comment
There was a problem hiding this comment.
LGTM, why did you add a semicolon?
Both cases should work with and without semicolon. You can write your entire React.js code without using semicolons. There are a few exceptions that rely on it, like a for loop. JavaScript also has Automatic Semicolon Insertion which interprets semicolons in places where they are critical and could break code. So it's totally up to you to use them or not. The only benefit might be readability.
esthicodes
left a comment
There was a problem hiding this comment.
LGTM!
Hard Work always pays off 👍🏻
| */ | ||
| function handleTitleChange(event) { | ||
| let newTodoTitle = event.target.value | ||
| let newTodoTitle = event.target.value; |
There was a problem hiding this comment.
did you find out when to use the semicolon (;)?
Use semi-colons at the end of return statements: This is especially helpful within the context of JS frameworks like react where a return statement can take up the whole function. It helps spot the difference between when the function logic ends and when the actual function ends.
There was a problem hiding this comment.
I will use semicolon only at the end of a statement from now on. It is a hold over from writing JS code with frequent use of semicolon. In some React code I've seen I had seen frequent semicolon use also. For example after import files at or exporting the default component.
Submission of code for lesson-1-4.