-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
CYF ITP South Africa - Cape Town | Dawud Vermeulen | Module-Structuring-and-Testing-Data | Week 3 #216
base: main
Are you sure you want to change the base?
CYF ITP South Africa - Cape Town | Dawud Vermeulen | Module-Structuring-and-Testing-Data | Week 3 #216
Conversation
…i started building immediately but still TDD. why is the implementation rounds not finishing in this sprint?!
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.
Here is some feedback
@@ -0,0 +1,11 @@ | |||
module.exports = function getAngleType(angle) { | |||
if (angle === 90) return 'Right angle'; | |||
if (angle < 90) return 'Acute angle'; |
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.
Bear in mind that the code is executed line-by-line, so the function will return 'acute angle' for anything less than or equal to 0. How would you remedy this?
@@ -0,0 +1,11 @@ | |||
module.exports = function getAngleType(angle) { | |||
if (angle === 90) return 'Right angle'; |
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.
Not wrong, but is it really best practice to use only "if" statements in this instance?
module.exports = function getAngleType(angle) { | ||
if (angle === 90) return 'Right angle'; | ||
if (angle < 90) return 'Acute angle'; | ||
if (angle > 90 && angle < 180) return 'Obtuse angle'; |
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.
While this is not wrong, note that code often doesn't need everything written in explicit detail and can interpret things based on implications, so it's best to avoid redundancy to keep the code as neat and succinct as possible. Do you see which boolean in the above line of code and one of the lines below may be redundant?
@@ -0,0 +1,16 @@ | |||
function repeat(str,count){ |
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.
Instructions stated that function should return a string. E.g. "robin" repeated 3 times should return "robinrobinrobin".
@@ -0,0 +1,6 @@ | |||
function cardValidator(cardNumber){ |
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.
Where are the contents of the function?
if (num <= 1) { | ||
return false; | ||
} // add this for only positive integers | ||
for (let i = 2; i <= num/2; i++) { // change to a for loop. start at lowest prime 2, stop at num (but maybe makes more sense to be num/2). |
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.
This is correct, but is "num/2" really the most efficient stopping point for the loop?
return false; | ||
} // add this for only positive integers | ||
for (let i = 2; i <= num/2; i++) { // change to a for loop. start at lowest prime 2, stop at num (but maybe makes more sense to be num/2). | ||
if (num % i === 0 && i !== num) { // embed a if that checks for the match |
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.
At what point in the loop is 'i' going to be equal to 'num'?
@@ -20,6 +20,6 @@ console.log(find("code your future", "z")); | |||
// Pay particular attention to the following: | |||
|
|||
// a) How the index variable updates during the call to find |
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.
You did not answer question 'a'
Learners, PR Template
Self checklist
Changelist
Questions
I have raised my questions in the workshop and on Slack