generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 195
Glasgow | ITP May -25 | Pandi Simatupang | Module-Structuring-and-Testing-Data | coursework/sprint-2 #650
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
PandiSimatupang
wants to merge
13
commits into
CodeYourFuture:main
Choose a base branch
from
PandiSimatupang:coursework/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
Glasgow | ITP May -25 | Pandi Simatupang | Module-Structuring-and-Testing-Data | coursework/sprint-2 #650
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a673f00
solve and comment sprint-2/1-key-errors/0.js
PandiSimatupang 95d7600
solve and comment sprint-2/1-key-errors/1.js
PandiSimatupang 089cd0a
solve and comment sprint2/1-key-errors/2.js
PandiSimatupang c18750b
solve and comment sprint2/2-mandatory-debug/0.js
PandiSimatupang e289031
solve and comment sprint2/2-mandatory-debug/1.js
PandiSimatupang 743e9a8
solve and comment sprint-2/2-mandatory-debug/2.js
PandiSimatupang 60dd470
solve and comment sprint2/3-mandatory-implement/1-bmi.js
PandiSimatupang c26acb4
solve and comment sprint-2/3-mandatory-implement/2-cases.js
PandiSimatupang 7966e09
solve and commit sprint-2/3-mandatory-implement/3-to-pounds.js
PandiSimatupang 83d8bc9
comment Sprint-2/4-mandatory-interpret/time-format.js
PandiSimatupang 8b56abf
solve Sprint-2/5-stretch-extend/format-time.js
PandiSimatupang d30acb6
update
PandiSimatupang 6a4f2b8
change string to character Sprint-2/1-key-errors/0.js
PandiSimatupang 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,21 @@ | ||
// Predict and explain first... | ||
// =============> write your prediction here | ||
//the function will turn the first given character into Uppercase. | ||
|
||
// call the function capitalise with a string input | ||
// interpret the error message and figure out why an error is occurring | ||
|
||
function capitalise(str) { | ||
let str = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
return str; | ||
let strWithUpperCase = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
return strWithUpperCase; | ||
} | ||
|
||
// =============> write your explanation here | ||
// str[0].toUpperCase() ---> gets the first character and uses build-in method to convert a char to uppercase | ||
// str.slice(1) ----> will slice the array or sting "start from 1" to the rest of array or string | ||
// we get an error because we "re-declare" the str variable as parameter and as call back of expression | ||
|
||
// =============> write your new code here | ||
|
||
const myStr = "i forgot add this string"; | ||
console.log(capitalise(myStr)); |
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,20 +1,27 @@ | ||
|
||
// Predict and explain first BEFORE you run any code... | ||
|
||
//>>>>>sure, it | ||
// this function should square any number but instead we're going to get an error | ||
|
||
// =============> write your prediction of the error here | ||
//the function will return square for every given number. | ||
|
||
function square(3) { | ||
return num * num; | ||
} | ||
// function square(3) { | ||
// return num * num; | ||
// } | ||
|
||
// =============> write the error message here | ||
// ans: Unexpected number | ||
|
||
// =============> explain this error message here | ||
|
||
// ans: function need num to be defined, instead parameter was given 3 as literal value that does not point to any variable as parameter | ||
// Finally, correct the code to fix the problem | ||
|
||
// =============> write your new code here | ||
|
||
function square(num) { | ||
return num * num; | ||
} | ||
|
||
mynum = 3; //define the num | ||
|
||
console.log(square(mynum)); //verify the result |
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,20 @@ | ||
// Predict and explain first... | ||
|
||
// =============> write your prediction here | ||
// function will return with result of multiplication of given parameters (i,e: a times b) | ||
// function multiply(a, b) { | ||
// console.log(a * b); | ||
// } | ||
|
||
function multiply(a, b) { | ||
console.log(a * b); | ||
} | ||
|
||
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); | ||
// console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); | ||
|
||
// =============> write your explanation here | ||
|
||
// the function does not return any thing, so as result ${multiply(10, 32)} --> will return as "undefined" | ||
// 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,23 @@ | ||
// Predict and explain first... | ||
// =============> write your prediction here | ||
// sure this function wont work because, hang on.. I should predict and pretend that everything is fine | ||
// the function will return with summary of given parameters and console.log will verify it | ||
|
||
function sum(a, b) { | ||
return; | ||
a + b; | ||
} | ||
// function sum(a, b) { | ||
// return; | ||
// a + b; | ||
// } | ||
|
||
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); | ||
// console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); | ||
|
||
// =============> write your explanation here | ||
//function will execute line the code and escape from the function block whenever it "sees" return.. it will return with any expression put on it | ||
// in this function a+b which is expected as the result is placed after return line because return has ";" so i wont bother look the next line. | ||
// just remove the semicolon next to the return.. and put a+b instead, because some how "prettier" as trusty worthy formatter for this course will always add extra ; for every logical expression (somehow).. :) xixixixi | ||
// 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
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
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.
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.
It is important to note that
;
[semicolon] is not needed in this case for the function to return when it reaches thereturn
statement. New line is also a valid way to end the line, thus the function will not executea + b
even if we were missing a;
.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.
Thanks, I used to think that a semicolon marked is the end of a statement, but now I know that a newline (\n) can also signify the end.