-
-
Notifications
You must be signed in to change notification settings - Fork 387
Manchester | 26-ITP-May | Abdu Hassen | Sprint 2 | structure and testing data #1435
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,22 @@ | ||
|
|
||
| // 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 | ||
| // =============> write your prediction of the error here: it will throw an error because in the parameter(placeholder) | ||
| // there is constant value which js does not recognize. | ||
|
|
||
| function square(3) { | ||
| return num * num; | ||
| return num * num; | ||
| } | ||
|
|
||
| // =============> write the error message here | ||
| // =============> write the error message here: the error message SyntaxError: Unexpected number | ||
|
|
||
| // =============> explain this error message here | ||
| // =============> explain this error message here: syntax error, meaning it fails before the function even gets defined. | ||
| // JS expects a parameter slot to contain a name (identifier) and gets confused | ||
| // when it sees a raw number sitting there instead. | ||
|
|
||
| // Finally, correct the code to fix the problem | ||
|
|
||
| // =============> write your new code here | ||
|
|
||
|
|
||
| // =============> write your new code here: function square(num) { | ||
| // return num * num; | ||
| // } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,22 @@ | ||
| // Predict and explain first... | ||
|
|
||
| // =============> write your prediction here | ||
| // =============> write your prediction here: My prediction is that in this function there is two console.log | ||
| // the result of this two log will print one with the value only 320 and | ||
| // the other one with the sentences of the log not the value. | ||
|
|
||
| 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: because of the log inside the function the outside function can't access the result so the log will print | ||
| // one with the value only and second console.log will print the sentences with explanation of the result and | ||
| // undefined value because the the function doesn't access the operation. | ||
|
|
||
| // Finally, correct the code to fix the problem | ||
| // =============> write your new code here | ||
| // =============> 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)}`); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| // Predict and explain first... | ||
|
|
||
| // Predict the output of the following code: | ||
| // =============> Write your prediction here | ||
| // =============> Write your prediction here: the code is already declared a variable that can not be changed so the consol.log always be the same 3. | ||
|
|
||
| const num = 103; | ||
|
|
||
|
|
@@ -14,11 +14,15 @@ 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 | ||
| // =============> write the output here: 3 | ||
| // Explain why the output is the way it is | ||
| // =============> write your explanation here | ||
| // =============> write your explanation here: the code is already declared a variable that can not be changed in the | ||
| // first place so when ever the process try to access another console.log it will take the same value as before | ||
| // so the consol.log always be the same. | ||
| // Finally, correct the code to fix the problem | ||
| // =============> write your new code here | ||
| // =============> write your new code here: function getLastDigit(num) { | ||
| // return num.toString().slice(-1); | ||
|
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. What does |
||
| // } | ||
|
|
||
| // This program should tell the user the last digit of each number. | ||
| // Explain why getLastDigit is not working properly - correct the problem | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,3 +14,8 @@ | |
| // You will need to come up with an appropriate name for the function | ||
| // Use the MDN string documentation to help you find a solution | ||
| // This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase | ||
|
|
||
| function toCapitalizedSnakeCase(str) { | ||
|
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. Is this capitalising each word or does it uppercase the whole word, because your function name tells me one thing but its return output gives me another. |
||
| const toCapitalized = str.toUpperCase().replace(/ /g, "_"); | ||
| return toCapitalized; | ||
| } | ||
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.
How does javascript see
undefined?What does this tell you about js that it returns
undefined?