generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 240
ITP-JAN2025-London|Sabita-Shrestha|Module-Structuring-and-Testing-Data|Week6|2sprint #277
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
Closed
SabitaShrestha325
wants to merge
6
commits into
CodeYourFuture:main
from
SabitaShrestha325:Coursework-planner-sprint2
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b64f45a
sprint2 key-errors
SabitaShrestha325 d9cd236
2-mandatory-debug
SabitaShrestha325 74649af
sprint2 debugging
SabitaShrestha325 fe81c57
3-mandatory-implement
SabitaShrestha325 af447a3
4-mandatory-interpret
SabitaShrestha325 cb674b4
Made changes
SabitaShrestha325 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,22 @@ | ||
| // Predict and explain first... | ||
| // =============> write your prediction here | ||
| // =============> write your prediction here: | ||
| // there is promblem declaring the string twice. | ||
|
|
||
| // 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; | ||
| } | ||
| //function capitalise(str) { | ||
| // let str = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
| // return str; | ||
|
|
||
| //} | ||
|
|
||
| // =============> write your explanation here: It say's syntax error "str" has been declared twice. We can change variable name in tp text or anything else | ||
|
|
||
| // =============> write your explanation here | ||
| // =============> write your new code here | ||
|
|
||
| function capitalise(text) { | ||
| let capitalisedText = `${text[0].toUpperCase()}${text.slice(1)}`; | ||
| return capitalisedText; | ||
| } | ||
| console.log(capitalise("hello world")); |
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... | ||
|
|
||
| // Why will an error occur when this program runs? | ||
| // =============> write your prediction here | ||
| // =============> write your prediction here: const decimalNumber = 0.5; this line should be declare outside of function | ||
|
|
||
| // Try playing computer with the example to work out what is going on | ||
|
|
||
| function convertToPercentage(decimalNumber) { | ||
| const decimalNumber = 0.5; | ||
| const percentage = `${decimalNumber * 100}%`; | ||
| //function convertToPercentage(decimalNumber) { | ||
| // const decimalNumber = 0.5; | ||
| //const percentage = `${decimalNumber * 100}%`; | ||
|
|
||
| return percentage; | ||
| } | ||
| //return percentage; | ||
| //} | ||
|
|
||
| console.log(decimalNumber); | ||
| //console.log(decimalNumber); | ||
|
|
||
| // =============> write your explanation here | ||
| // =============> write your explanation here: In line 9 const decimalNumber = 0.5; should not be in their because it will redeclare in side function which will be error, it will be local scope if its inside a function. declaring outside of code make global scope, can call through out the code. | ||
|
|
||
| // Finally, correct the code to fix the problem | ||
| // =============> write your new code here | ||
| const decimalNumber = 0.5; | ||
| function convertToPercentage(decimalNumber){ | ||
| const percentage = `${decimalNumber*100}%`; | ||
| return percentage; | ||
|
|
||
| } | ||
| console.log(decimalNumber); |
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,16 @@ | ||
| // Predict and explain first... | ||
|
|
||
| // =============> write your prediction here | ||
| // =============> write your prediction here: there is no return statement | ||
|
|
||
| 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 | ||
| // =============> write your explanation here; | ||
| //multiply function is logged with out define so the result will be undefined, need add return statement to complete it. | ||
|
|
||
| // 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,17 @@ | ||
| // Predict and explain first... | ||
| // =============> write your prediction here | ||
| // =============> write your prediction here: there is ; error | ||
|
|
||
|
|
||
|
|
||
| // =============> write your explanation here: function will be undefined because of ";" by removing ; placing a+b in same line will return function. | ||
| // Finally, correct the code to fix the problem | ||
| // =============> write your new code here | ||
| function sum(a, b) { | ||
| return; | ||
| a + b; | ||
| return a+b; | ||
|
|
||
| } | ||
|
|
||
| console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); | ||
| //Between "return value" and "function", which one is undefined? | ||
|
|
||
| // =============> write your explanation here | ||
| // Finally, correct the code to fix the problem | ||
| // =============> write your new code here | ||
| //return value will be undefined if function have not return statement it will automatically returns undefined. | ||
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,38 @@ | ||
| // Predict and explain first... | ||
| // Predict and explain first...because of const num, it won't change output. | ||
|
|
||
| // Predict the output of the following code: | ||
| // =============> Write your prediction here | ||
| // =============> Write your prediction here: 3 | ||
|
|
||
| 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)}`); | ||
| 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 | ||
| // =============> write the output here: 3 for all console.log. | ||
| // Explain why the output is the way it is | ||
| // =============> write your explanation here | ||
| // =============> write your explanation here: 3 for all of the the console.log because it won't take any argument it will always take global variable num = 103. | ||
| // Finally, correct the code to fix the problem | ||
| // =============> write your new code here | ||
|
|
||
| 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)}`); | ||
|
|
||
| // Does the function toPounds() return the last digit of the given parameter? | ||
| // No, it doesn't return toPounds() of the last digit of the given parameter. | ||
|
|
||
|
|
||
|
|
||
|
|
||
| // This program should tell the user the last digit of each number. | ||
| // Explain why getLastDigit is not working properly - correct the problem | ||
| //because of line 6. |
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.
Between "return value" and "function", which one is undefined?