-
-
Notifications
You must be signed in to change notification settings - Fork 221
LONDON | GISLAINE DELLA BELLA | Module-Structuring-and-Testing-Data | WEEK 3 #192
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
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.
Thanks for putting so much effort into this. There are a few things I would love you to always take note of before pushing to Github.
- Check and remove any commented code as they serve no purpose to your code
- Check and remove any console.log from your code
- Try to run your tests locally and ensure that they are all passing before pushing your code to Github.
console.log(getCardValue("A♠")); // Output: 11 | ||
console.log(getCardValue("10♣")); // Output: 10 | ||
console.log(getCardValue("K♦")); // Output: 10 | ||
console.log(getCardValue("5♥")); // Output: 5 | ||
console.log(getCardValue("2♠")); // Output: 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.
Remember always to remove console logs
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.
ok
Sprint-3/implement/get-card-value.js
Outdated
const cardValues = { | ||
A: 11, | ||
K: 10, | ||
Q: 10, | ||
J: 10, | ||
10: 10, | ||
9: 9, | ||
}; |
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.
I don't see this being used anywhere. Please can you explain what it is used for?
return parseInt(rank, 10); | ||
} | ||
} | ||
module.exports = getCardValue; |
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.
Nice work on your implementations so far. But what happens when I pass an invalid number or an unrecognized card face?
// Handle Number Cards (2-10): | ||
// Given a card with a rank between "2" and "9", | ||
// When the function is called with such a card, | ||
// Then it should return the numeric value corresponding to the rank (e.g., "5" should return 5). |
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.
These comments are best written using describe blocks as they are easy to maintain and reason about when reading the code in the future. For example, we can write the above comments as describe blocks as follows.
describe("Handle Number Cards (2-10)", () => {
test("should return the numeric value for a given card rank", () => {
// Your actual test
});
});
Please write your test to follow the above pattern
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.
done ;)
test(`return true if numerator <0 && >= 1`, function () { | ||
const numerator = -4; | ||
const denominator = 7; | ||
const currentInput = isProperFraction(numerator, denominator); | ||
const targetInput = true; | ||
}); | ||
|
||
// Equal Numerator and Denominator check: | ||
//is not a proper fraction because the numerator is | ||
// equal to the denominator. | ||
//The function should return false | ||
|
||
test(`return false is numerator and demominator are the same`, function () { | ||
const numerator = 3; | ||
const denominator = 3; | ||
const currentInput = isProperFraction(numerator, denominator); | ||
const targetInput = false; | ||
}); | ||
|
||
test(`return false is numerator and demominator are the same`, function () { | ||
const numerator = 5; | ||
const denominator = 5; | ||
const currentInput = isProperFraction(numerator, denominator); | ||
const targetInput = 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.
These tests don't seem to have any assertions. Why is this the case?
Sprint-3/revise/implement/repeat.js
Outdated
const repeatedString1 = repeat("Hello", 3); | ||
console.log(repeatedString1); // Output: "HelloHelloHello" | ||
|
||
const repeatedString2 = repeat("Apple is red", 1); | ||
console.log(repeatedString2); // Output: "Apple is red" | ||
|
||
const repeatedString3 = repeat("Banana is yellow", 0); | ||
console.log(repeatedString3); // Output: "" | ||
|
||
try { | ||
const repeatedString4 = repeat("Orange is orange", -1); | ||
console.log(repeatedString4); | ||
} catch (error) { |
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.
Why not have a test file instead?
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.
Add Tests
Sprint-3/revise/implement/repeat.js
Outdated
// Implement a function repeat | ||
|
||
function repeat(str, num) { | ||
return str.repeat(num); |
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.
Would be nice if you could actually implement the functionality instead of using the built-in one
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.
New Function
test("Should validate a number with at least 5 characters", () => { | ||
const input = 112206; | ||
const output = isNumberValid(input); | ||
expect(output).toBe(true); // A valid number |
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 should be invalid as the password does not pass all of the criteria.
These are the criteria as password that a valid password need to pass
Have at least 5 characters.
- Have at least one English uppercase letter (A-Z)
- Have at least one English lowercase letter (a-z)
- Have at least one number (0-9)
- Have at least one non-alphanumeric symbol ("!", "#", "$", "%", ".", "*", "&")
- Must not be any previous password in the passwords array.
first and get that working | ||
*/ | ||
|
||
function isNumberValid(input) { |
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.
I don't believe this function is doing what it should. Please check the requirements and update your code.
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.
Fixed Password function & and Tests
} else { | ||
return number + "th"; | ||
} | ||
} |
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 looks good but can you test for 111, 112 and 113? I don't think your code covers them correctly
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 were right. I fixed the function now.
Hello Codex, Thanks for taking the time to review my code. Honestly, I was a bit lost with these exercises, and I know I need to go over them again. I’ll ask someone for help during the next in-person class. I appreciate your time and feedback! Best, |
… between 11 and 13. If so, the suffix should be "th".
Learners, PR Template
Self checklist
Changelist
Hi volunteer, good evening
Here is my PR for the Sprint 3.
I have to confess this was the most hard practice so far. The exercises in Implementing directry were so hard for me.
I did need so much help and I know I still have a long way to go to fully understand them.
It was so frustrating but I realize that I’m at a point where I can read and explain the code, think about the operators, and identify some functions I’ll need. However, I haven’t yet reached the point where I can confidently write this JavaScript syntax on my own.
Jumping to the folder Revise it was a completely different experience—much more enjoyable and easier to follow. It gave me hope again that I can do this!
Looking forward to starting the next step.
thank you again for your time and help,
Gislaine
Questions
Ask any questions you have for your reviewer.