-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
NW6 | Haythem Mohammed | Module-JS1 | Week4 #175
base: main
Are you sure you want to change the base?
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.
Comment about nested 'else if' in password-validator.js and recommendation to use a 'switch statement' instead.
else {console.log("Valid!");} | ||
|
||
} | ||
passValidat("1a1*1F1"); |
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 code works fine. However this bit /[^\w\s']/g
This includes special characters, which contradicts the requirement for the password to contain at least one symbol. It would be better if you update it using this: const regex = /[^\w\s\d]/g;
week-4/implement/repeat.test.js
Outdated
else {console.log(str);} | ||
} | ||
} | ||
rePeat("My name is Haythem. I am a software developer in CYF", 3); |
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 think the issue here is your code (if (count < 0)) is inside the loop. try putting it outside the loop, you might want to use <= instead of < to include the case where count is 0.for example: function rePeat(str, count) {
if (count <= 0) {
console.log("Error: Your input is non-positive");
} else {
for (let i = 0; i < count; i++) {
console.log(str);
}
}
}
rePeat("My name is Haythem. I am a software developer in CYF", 3);
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.
Be careful with the requirements in this task. In a few places, the cases mention "return a new string", so we need the function to give something back rather than logging out the result.
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.
Be careful of the requirement that says the function "should return a boolean"
|
||
|
||
test ("Get Ordinals", function () { | ||
expect(getOrdinal(41)).toBe('st') |
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.
There's a lot of different branches that the code can take in the function. It would be really good to get a few more test cases to make sure there's good coverage!
@@ -15,3 +15,19 @@ | |||
// And a character char that does not exist within the case-sensitive str, | |||
// When the function is called with these inputs, | |||
// Then it should return 0, indicating that no occurrences of the char were found in the case-sensitive str. | |||
|
|||
function countChar(str, char) { |
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.
Excellent work Haythem!
let cardNumber = '1009000100000108'; | ||
cardNumber = cardNumber.replace(/\D/g, ''); // to remove any non digits. | ||
function creditCardLength(cardNumber) { // the function is to check card number length. | ||
let theLength = (Math.log(Math.abs(cardNumber)+1) * 0.43429448190325176 | 0) + 1; |
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 seems like complicated logic to get the length of the credit card number. Can you think of a simpler way to get the length of the string?
Great work @haythem-f. Just be careful of formatting (all code should be formatted using Prettier), and your branches. There's work coming from other weeks into your pull requests. I would recommend checking out the main branch ( |
Learners, PR Template
Self checklist
Changelist
Briefly explain your PR.
Questions
Ask any questions you have for your reviewer.