Manchester | 26-ITP-May | Abdu Hassen | Sprint 2 | structure and testing data #1435
Manchester | 26-ITP-May | Abdu Hassen | Sprint 2 | structure and testing data #1435Abduhasen wants to merge 3 commits into
Conversation
| // =============> write your explanation here | ||
| // =============> write your explanation here: firstly the process start accepting that it is a function and takes | ||
| // the parameter to hold the place then it go through the function but by the 5th line | ||
| // the function return and the value will come out undefined |
There was a problem hiding this comment.
How does javascript see undefined?
What does this tell you about js that it returns undefined?
There was a problem hiding this comment.
- javascript sees
undefinedas if there is no value assigned and it is returning with out a value. - this tell me about javascript if we didn't assigned a value to and if the terminate the function with out returning it will see it as value not given to it and it doesn't know the value.
There was a problem hiding this comment.
One nice video explaining it a little further -> https://www.youtube.com/watch?v=EKsheWTwgok
There was a problem hiding this comment.
So good way to explain undefined is when the variable exists but no values has been assigned to it, also java script assignee undefined when the variable have no value.
| // 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.
What does -1 represent when passing into slice?
There was a problem hiding this comment.
- when using
sliceif we apple-1to thesliceit represent that it is starting from the last index but not including it.
| // 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.
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.
There was a problem hiding this comment.
1.the function is about changing all the given string to uppercase and also to snakecase and i changed the function name to more understandable name toUpperSnakeCase
There was a problem hiding this comment.
You will also need to update the toCapitalize variable name to match the intention of the function, otherwise its still doesn't read correctly.
Once this is done I can approve your PR :)
Well done
There was a problem hiding this comment.
I changed the variable name to match the intention of the function I named it convertToUpperSnakeCase. Thank you for the feedback's they are constructive and i gain more concepts.
Learners, PR Template
Self checklist
Changelist
1.interpreting of codes with explanation.
2.fixing errors.
3.writing a code depending on a given statement.
4.debugging of code.
Questions
N/A