-
-
Notifications
You must be signed in to change notification settings - Fork 546
London | 26-ITP-Sep | Alan Mak | Sprint 3 | Module-JavaScript-Fundamentals Coursework #1619
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
AlanGit-debug2604
wants to merge
26
commits into
CodeYourFuture:main
Choose a base branch
from
AlanGit-debug2604:acoursework/sprint-3
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
26 commits
Select commit
Hold shift + click to select a range
576dc5a
Predicted what I expect, explained Syntax Error, added the new code
342efc6
deleted old code in 0.js
f47f36b
1.js result predicted, explained the errors, and wrote new code
41e9a7a
1.js old code deleted
9c61083
2.js SyntaxError expected, explained the error, wrote new code, delet…
3ecd296
grammar correction
55f005d
2-mandatory-debug 0.jsedited, expectation stated, code fixed
AlanGit-debug2604 bc68642
2-manadatory-debug 0.js edited, expectation stated
AlanGit-debug2604 a243d6d
2-mandatory-debug 1.jsedited, expectation stated, code fixed
AlanGit-debug2604 1b09621
2-mandatory-debug 0.js added Undefined in expectation.
742ac3f
2-mandatory-debug 2.js edited, result predicted, prediction compared,…
9ba67d2
3-mandatory-implement 1-bmi.js Implemented BMI calculation function a…
6be655b
Fix typo in comment explaining undefined behavior in multiply function
cf2bf33
3-mandatory-implement 2-cases.js Implemented upperSnakeCase function …
9a86ff0
3-mandatory-implement 3-to-pounds.js Implement toPound function to co…
0142183
3-to-pound.js : Refactor parameter name (wholePenceStringWithP) in to…
c4affdd
formatTime.js formatAs12HourClock function to correctly handle hour i…
d35a846
Remove Prep folder files from PR
214b717
Removed empty files
8e32548
Remove Prep files from PR
1d3a340
3-to-pound.js: added test cases
b8dc470
use by Method .toFixed(1) to return BMI in string in one decimal place
773c6bc
format-time.js edited to run `const` minutes =time.slice(-2); and fi…
01c7b46
Fix time formatting for hours >= 24 and ensure leading zeros for sing…
fe78cd5
Refactor time formatting logic to correctly handle hours between 12 a…
fa9defb
Fix time formatting to handle hours >= 24 and adjust AM/PM representa…
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
Some comments aren't visible on the classic Files Changed page.
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,12 @@ | ||
| // Predict and explain first... | ||
| // =============> write your prediction here | ||
| // =============> I expect the function capitalise will turn first letter of string given by user into capital letter. | ||
|
|
||
| // call the function capitalise with a string input | ||
| // interpret the error message and figure out why an error is occurring | ||
|
|
||
| // =============> The result was a Syntax error because str has been declared as parameter of function captialise before let reassign str. | ||
| // =============> | ||
| function capitalise(str) { | ||
| let str = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
| str = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
| return str; | ||
| } | ||
|
|
||
| // =============> write your explanation here | ||
| // =============> write your new code here | ||
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,17 @@ | ||
| // Predict and explain first... | ||
|
|
||
| // Why will an error occur when this program runs? | ||
| // =============> write your prediction here | ||
| // =============> SyntaxError will occurs | ||
|
|
||
| // Try playing computer with the example to work out what is going on | ||
|
|
||
| // =============> decimalNumber first declared as parameter, it cannot be reassigned as const. | ||
| // Also, console.log try to run decimalNumber as a variable while decimalNumber was assigned as a parameter. | ||
| // Finally, correct the code to fix the problem | ||
| // =============> write your new code here | ||
| function convertToPercentage(decimalNumber) { | ||
| const decimalNumber = 0.5; | ||
| const percentage = `${decimalNumber * 100}%`; | ||
|
|
||
| return percentage; | ||
| } | ||
|
|
||
| console.log(decimalNumber); | ||
|
|
||
| // =============> write your explanation here | ||
|
|
||
| // Finally, correct the code to fix the problem | ||
| // =============> write your new code here | ||
| console.log(convertToPercentage(0.5)); |
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,17 @@ | ||
|
|
||
| // Predict and explain first BEFORE you run any code... | ||
|
|
||
| // this function should square any number but instead we're going to get an error | ||
|
|
||
| // =============> write your prediction of the error here | ||
|
|
||
| function square(3) { | ||
| return num * num; | ||
| } | ||
| // =============> I expect SyntaxError will result | ||
|
|
||
| // =============> write the error message here | ||
| // =============> SyntaxError: Unexpected number | ||
|
|
||
| // =============> explain this error message here | ||
| // =============> Numerical character "3" cannot be named as parameter of a function. | ||
|
|
||
| // Finally, correct the code to fix the problem | ||
|
|
||
| // =============> write your new code here | ||
|
|
||
|
|
||
| function square(num) { | ||
| return num * num; | ||
| } | ||
| console.log(square(3)); |
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,18 @@ | ||
| // Predict and explain first... | ||
|
|
||
| // =============> write your prediction here | ||
| // =============> Undefined at the end of sentence. console.log in local function will result the product. But console.log in global scope will not call function multiply. | ||
|
|
||
| function multiply(a, b) { | ||
| console.log(a * b); | ||
| } | ||
|
|
||
| console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); | ||
| //function multiply(a, b) { | ||
| // console.log(a * b); | ||
| //} | ||
|
|
||
| // =============> write your explanation here | ||
| //console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); | ||
|
|
||
| // =============> The function multiply does not really carry out the multiplication. It only logs the result of a*b. That's why calling multiply become 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,18 @@ | ||
| // Predict and explain first... | ||
| // =============> write your prediction here | ||
| // =============> I predict a SyntaxError in original code | ||
|
|
||
| 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 | ||
| // =============> Expression a + b is not assigned to return. | ||
| // 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,36 @@ | ||
| // Predict and explain first... | ||
|
|
||
| // Predict the output of the following code: | ||
| // =============> Write your prediction here | ||
| // =============> Code returns last digit of 103 which is the value of num assigned in global scope. | ||
|
|
||
| //const num = 103; | ||
|
|
||
| //function getLastDigit() { | ||
| // return num.toString().slice(-1); | ||
| //} | ||
|
|
||
| //console.log(`The last digit of 42 is ${getLastDigit(42)}`); | ||
| //console.log(`The last digit of 105 is ${getLastDigit(105)}`); | ||
| //console.log(`The last digit of 806 is ${getLastDigit(806)}`); | ||
|
|
||
| // Now run the code and compare the output to your prediction | ||
| // =============> | ||
| // The last digit of 42 is 3 | ||
| // The last digit of 105 is 3 | ||
| // The last digit of 806 is 3 | ||
| // Explain why the output is the way it is | ||
| // =============> The function refers to the value of `num` assigned in global scope rather than getLastDigit, because 'num' was not a parameter in function name. | ||
| // Finally, correct the code to fix the problem | ||
| // =============> | ||
| const num = 103; | ||
|
|
||
| function getLastDigit() { | ||
| function getLastDigit(num) { | ||
| return num.toString().slice(-1); | ||
| } | ||
|
|
||
| console.log(`The last digit of 42 is ${getLastDigit(42)}`); | ||
| console.log(`The last digit of 105 is ${getLastDigit(105)}`); | ||
| console.log(`The last digit of 806 is ${getLastDigit(806)}`); | ||
|
|
||
| // Now run the code and compare the output to your prediction | ||
| // =============> write the output here | ||
| // Explain why the output is the way it is | ||
| // =============> write your explanation here | ||
| // Finally, correct the code to fix the problem | ||
| // =============> write your new code here | ||
|
|
||
| // This program should tell the user the last digit of each number. | ||
| // Explain why getLastDigit is not working properly - correct the problem |
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.
Uh oh!
There was an error while loading. Please reload this page.