-
Couldn't load subscription status.
- Fork 16
Develop #11
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: develop
Are you sure you want to change the base?
Develop #11
Conversation
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.
Please check all of my reviews and don't hesitate for asking me if you have any questions. Thank you very much.
| * @param {number} sequence | ||
| */ | ||
| function generateFibonacciUsingLoop(sequence) { | ||
| // write your code here |
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.
Remove this unnecessary comment.
| fibonacci.pop(); | ||
| return fibonacci; |
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.
Please set a line break between each part of your code. For example:
fibonacci.pop();
return fibonacci;So the other team will easily read your code.
| let fibonacci = [0, 1]; | ||
|
|
||
| if (sequence == 1) { | ||
| fibonacci.pop(); | ||
| return fibonacci; | ||
| } else if (sequence == 2) { | ||
| return fibonacci; | ||
| } |
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.
If you have else if code with return statement like this, you can make it more readable by writing it this way.
let fibonacci = [0, 1];
if (sequence == 2) {
return fibonacci;
}
if (sequence == 1) {
fibonacci.pop();
return fibonacci;
}| * @param {number} sequence | ||
| */ | ||
| function generateFibonacciUsingRecursive(sequence) { | ||
| // write your code here |
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.
See my review at #11 (comment).
| } | ||
| return array; |
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.
See my review at #11 (comment).
| value = value.replace(/[^a-zA-Z]/g, "").toLowerCase(); | ||
| let valueLen = value.length; | ||
|
|
||
| for (let index = 0; index < Math.floor(valueLen / 2); index++) { | ||
| if (value[index] !== value[valueLen - index - 1]) { | ||
| return false; | ||
| } | ||
| } | ||
| return true; |
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.
See my review at #11 (comment).
| value = value.replace(/[^a-zA-Z]/g, "").toLowerCase(); | ||
| if (index >= Math.floor(value.length / 2)) { | ||
| return true; | ||
| } | ||
| if (value[index] !== value[value.length - 1 - index]) { | ||
| return false; | ||
| } |
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.
See my review at #11 (comment).
| const resultObj = new Fibonacci(sequence); | ||
| if (method === "loop") { | ||
| result = resultObj.generateFibonacciUsingLoop(sequence); | ||
| } else if (method === "recursive") { | ||
| result = resultObj.generateFibonacciUsingRecursive(sequence); | ||
| } else { | ||
| throw new Error("Method must be loop or recursive."); | ||
| } |
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.
We should keep our main code clear. So I think this "method" checking can be organized into one method on the Fibonacci class.
| const resultObj = new Factorial(n); | ||
|
|
||
| let result = 0; | ||
|
|
||
| if (method == "loop") { | ||
| result = resultObj.calculateFactorialUsingLoop(); | ||
| } else if (method == "recursive") { | ||
| result = resultObj.calculateFactorialUsingRecursive(); | ||
| } else { | ||
| throw new Error("Method must be loop or recursive."); | ||
| } |
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.
See my review at #11 (comment).
| let result; | ||
| if (method === "reverse") { | ||
| result = new Palindrome(word).isPalindromeUsingReverse(word); | ||
| } else if (method === "loop") { | ||
| result = new Palindrome(word).isPalindromeUsingLoop(word); | ||
| } else if (method === "recursive") { | ||
| result = new Palindrome(word).isPalindromeUsingRecursive(word); | ||
| } |
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.
See my review at #11 (comment).
I have completed challenges 1 and 2, please review my code. Thank you