-
-
Notifications
You must be signed in to change notification settings - Fork 546
london | 26-ITP-Sep | Maharit Belai | Sprint 3 | Module- Javascript Fundamental #1611
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
MaharitB
wants to merge
23
commits into
CodeYourFuture:main
Choose a base branch
from
MaharitB:coursework/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
23 commits
Select commit
Hold shift + click to select a range
dc1ecca
made a prediction on what the error could be and gave value by calli…
MaharitB ff58b19
gave explanation on the error message and wrote a code to fix the error
MaharitB a09f7df
wrote the fixed code and made the code with the bag comment
MaharitB 772f4ab
run prettier
MaharitB 34272f8
add predict and explain about the code
MaharitB cdb17fe
Interpret the error message
MaharitB aa750f6
correct code 1.
MaharitB 5816a40
correct code 2
MaharitB f51c24c
Predict and explain what the error might be
MaharitB 83b4a7b
run the code by calling the vanction with no value and the error message
MaharitB 22b0b87
Explain the error message
MaharitB 71935b5
correcet code that fixed the error
MaharitB 031eaf3
predit error and expplain outcome
MaharitB 54e0afb
correct code for o.js 2-mandatory debug
MaharitB b4c7cf2
write a preditction and explain
MaharitB 3923291
editted the prediction(wrote prediction and explanation in the same l…
MaharitB 364a5e9
predicted and explained the error of the code
MaharitB 96440cb
wrote the code again by fixing error
MaharitB fe28db6
made the first code and run and checked the newcode, displayed the ou…
MaharitB 6a25d50
Wrote the code and tested
MaharitB dfbeb67
wrote the code foe UPPER_SNAKE_CASE
MaharitB 92253f5
wrote the code and tested the code with different value
MaharitB 3301df8
run the code and answered the questions
MaharitB 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,19 @@ | ||
| // Predict and explain first... | ||
| // =============> write your prediction here | ||
| // on line 8, let declaring with name the same as the parameter | ||
|
|
||
| // 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)}`; | ||
| //It says syntax error Identifier 'str' has already been declared. | ||
| // function parameter and let which is inside the funtion can never | ||
| // be the same because both variables are in the same scope | ||
| // function capitalise(str) { | ||
| //let str = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
| //return str; | ||
| //} | ||
| //console.log(capitalise("error") | ||
| // | ||
| function capitalise(firstLetter) { | ||
| let str = `${firstLetter[0].toUpperCase()}${firstLetter.slice(1)}`; | ||
| return str; | ||
| } | ||
|
|
||
| // =============> write your explanation here | ||
| // =============> write your new code here | ||
| console.log(capitalise("error")); | ||
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,24 @@ | ||
|
|
||
| // 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(), shouldn't give a value to it , we can only pass | ||
| // an argument when the function is called, with value in it which is called argument. | ||
|
|
||
| function square(3) { | ||
| return num * num; | ||
| } | ||
| //function square(3) { | ||
| // return num * num; | ||
| //} | ||
| //console.log(square()) | ||
|
|
||
| // =============> write the error message here | ||
| // =============> Unexpected number | ||
|
|
||
| // =============> explain this error message here | ||
| // =============> unexpected number in the function, there should be only parameter there but here | ||
| // number is assigned instead of the variable name | ||
|
|
||
| // Finally, correct the code to fix the problem | ||
|
|
||
| // =============> write your new code here | ||
|
|
||
|
|
||
| function square(num) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct use of square function defination |
||
| 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 | ||
| // =============> there is no return,to return the value to the function call | ||
|
|
||
| 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 error is it is not printing out the function call in line 9. | ||
| // and returning is as undefined. | ||
|
|
||
| // Finally, correct the code to fix the problem | ||
| // =============> write your new code here | ||
| // Functiion 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
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,48 @@ | ||
| // Predict and explain first... | ||
|
|
||
| // Predict the output of the following code: | ||
| // =============> Write your prediction here | ||
| // =============> I think the num variable can be accesed by the funtion getLastDigit() | ||
| // so it means it is not using the argument that is passed by the function. | ||
| // the output for the three of function calls will be 3. | ||
|
|
||
| const num = 103; | ||
| //const num = 103; | ||
|
|
||
| function getLastDigit() { | ||
| return num.toString().slice(-1); | ||
| } | ||
| //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 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 | ||
| // The output is | ||
| // * 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 | ||
| // =============> write your explanation here | ||
| // * the output is the way it is because it was taking the num value | ||
| // from the variable num that has been declared and initialized outside the function. | ||
| // and const num has a global scope.if the function hasn't declared a variable num | ||
| // inisde the function it will use the gobaly declared and insialized variable num | ||
| // Finally, correct the code to fix the problem | ||
| // =============> write your new code here | ||
| // =============>function getLastDigit() { | ||
| const num = 103; | ||
|
|
||
| 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)}`); | ||
|
|
||
|
|
||
| // This program should tell the user the last digit of each number. | ||
| // yes it does tell the last digit of each number | ||
| // The last digit of 42 is 2 | ||
| // The last digit of 105 is 5 | ||
| // The last digit of 806 is 6 | ||
| // 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
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.
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.
correct use of function