generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 196
Sheffield | May-2025 | Declan Williams | Sprint-2 #565
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
CatchingKiyoko
wants to merge
17
commits into
CodeYourFuture:main
Choose a base branch
from
CatchingKiyoko: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
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
4cb9354
fix: resolve variable redeclaration error in capitalize function
CatchingKiyoko 2fafe6e
fix: comment out erroneous capitalize function to prevent redeclarati…
CatchingKiyoko 7620265
fix: correct parameter name in square function to prevent syntax erro…
CatchingKiyoko 071cf21
fix: add console log for square function with example input and corre…
CatchingKiyoko c1c09a6
update comments to clarify expected output and explanation in getLast…
CatchingKiyoko e72b13a
fix: correct getLastDigit function to accept parameters and return th…
CatchingKiyoko 832d9bb
fix: update explanation for getLastDigit function to clarify paramete…
CatchingKiyoko 2a18e2c
explained in comments why errors occured and then refactored the code…
CatchingKiyoko dde5917
fix: update multiply function to return the product instead of loggin…
CatchingKiyoko fdf492e
fix: correct sum function to return the sum of two numbers and update…
CatchingKiyoko 48d2e3a
feat: implement BMI calculation function and add example usage
CatchingKiyoko e2c65bf
feat: implement toUpperSnakeCase function to convert strings to UPPER…
CatchingKiyoko bb731c1
feat: implement toPounds function to convert pence strings to pounds …
CatchingKiyoko 8c166ff
fix: add console log and comments for clarity in formatTimeDisplay fu…
CatchingKiyoko 2f41d57
Update 1-bmi.js
CatchingKiyoko d04b7bd
Update 2-cases.js
CatchingKiyoko b860c0c
Merge branch 'CodeYourFuture:main' into coursework-Sprint-2
CatchingKiyoko 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,25 @@ | ||
// Predict and explain first... | ||
// =============> write your prediction here | ||
// I expect the code to possibly throw an error because str is being declared twice. once in the function and again in the function body declared as "let" | ||
// This function looks like its trying to turn the first letter of a string into a capital letter. | ||
|
||
// call the function capitalise with a string input | ||
// interpret the error message and figure out why an error is occurring | ||
// after trying to run the code it produced a "SyntaxError: Identifier 'str' has already been declared" | ||
|
||
function capitalise(str) { | ||
/* function capitalise(str) { | ||
let str = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
return str; | ||
} | ||
|
||
console.log(capitalise("hello")); */ | ||
// =============> write your explanation here | ||
// this is because the variable str is declared twice, once in the function parameters and again inside the function body with "let str" | ||
// str is declared as a parameter, so we don't need to declare it again with let you can just use it directly. | ||
// to fix the error, we can remove the "let" keyword from the second declaration of str. | ||
// =============> write your new code here | ||
|
||
function capitalize(str) { | ||
str = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
return str; | ||
} | ||
console.log(capitalize("the first letter should be capitalized")); |
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,24 @@ | ||
// Predict and explain first... | ||
// I expect the code to log the results of multiplying 10 and 32 but in line 10 i expect it to return undefined because the function "multiply" does not have a return statement. | ||
|
||
// =============> write your prediction here | ||
|
||
/* | ||
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 | ||
// The code defines a function "multiply" that takes two parameters "a" and "b" and logs their product to the console. However, it does not return any value from the function. | ||
// The function `multiply` is called with arguments 10 and 32, but since it does not return a value, the template literal will log "undefined" for the result of the multiplication. | ||
// and to fix this, the function should return the product instead of just logging it. | ||
|
||
|
||
// Finally, correct the code to fix the problem | ||
// =============> write your new code here | ||
|
||
function multiply(a, b){ | ||
return a * b; // Return the product instead of logging it | ||
} | ||
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); // now this will log the correct results |
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.
Uh oh!
There was an error while loading. Please reload this page.