generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 336
Scotland | ITP JAN-2026 | Tuan Nguyen | Sprint 2 | Comparisons-assertions-breaking-down-problems-sprint-2 #1183
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
Open
Jacknguyen4438
wants to merge
2
commits into
CodeYourFuture:main
Choose a base branch
from
Jacknguyen4438:comparisons-assertions-breaking-down-problems-sprint-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,29 @@ | ||
| // Predict and explain first... | ||
| // =============> write your prediction here | ||
|
|
||
| /* | ||
| My prediction is that this function will take the first letter of a string and capital it. | ||
| */ | ||
|
|
||
| // call the function capitalise with a string input | ||
| // interpret the error message and figure out why an error is occurring | ||
|
|
||
| function capitalise(str) { | ||
| /*function capitalise(str) { | ||
| let str = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
| return str; | ||
| } | ||
| }*/ | ||
|
|
||
| // =============> write your explanation here | ||
|
|
||
| /* | ||
| The main reason why the capitalise function have a not define error because the the str variable have been declare in the parameter | ||
| inside the function, the str variable is re-declare again that will break the rule of how variable work. | ||
| */ | ||
|
|
||
| // =============> write your new code here | ||
|
|
||
| function capitalise(str) { | ||
| let firstCapitaLetter = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
| return firstCapitaLetter; | ||
| }; | ||
| console.log(capitalise("hello")); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,32 @@ | ||
| // Predict and explain first... | ||
|
|
||
| // =============> write your prediction here | ||
| /* | ||
| The function multiply when is log into the terminal. we will receive a print out expression from | ||
| first console.log inside the function and undefined value from the string template inside the section console.log. | ||
| */ | ||
|
|
||
| /* | ||
| function multiply(a, b) { | ||
| console.log(a * b); | ||
| } | ||
|
|
||
| console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); | ||
| */ | ||
|
|
||
| // =============> write your explanation here | ||
| /* | ||
| First the function multiply have 2 parameter identifier a and b, the main purpose of this function is to multiply any argument that put | ||
| into the identifier a and b. Inside the the function is we have the function call console.log and nested inside is the expression from multiply of a and b. | ||
| However this will lead to error, since we need to return the expression(value) back to the function so it can be re used when call in a string template or other | ||
| function. | ||
|
|
||
| */ | ||
| // Finally, correct the code to fix the problem | ||
| // =============> write your new code here | ||
|
|
||
| function multiply(a, b) { | ||
| return a * b; | ||
| } | ||
|
|
||
| console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,27 @@ | ||
| // Predict and explain first... | ||
| // =============> write your prediction here | ||
|
|
||
| // The function sum when is call inside the string template. The print out will be "The sum of 10 and 32 is undefined". | ||
| /* | ||
| function sum(a, b) { | ||
| return; | ||
| a + b; | ||
| } | ||
|
|
||
| console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); | ||
|
|
||
| */ | ||
| // =============> write your explanation here | ||
|
|
||
| /* | ||
| For the function sum the writing format is correct but however instead of return the expression from the combine value | ||
| of a and b, right now there is no expression return back to the function. So when the function is used inside the string template, | ||
| it give the value of undefined instead of actual value of a and b combine together. | ||
| */ | ||
|
|
||
| // Finally, correct the code to fix the problem | ||
| // =============> write your new code here | ||
|
|
||
| function sum(a, b) { | ||
| return a + b; | ||
| } | ||
|
|
||
| console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
for example, the proper way to write this statement will be:
inside the function, the str variable is redeclared, which breaks the rule of how variables work.There are other examples in your work where wrong sentences are used.
The resources contained in this Link should help: BBC Learning English
Again, good Job!