Skip to content

West Midlands | Gabriel Deng | Module-Structuring-and-Testing-Data | Sprint 3#207

Closed
gai93003 wants to merge 4 commits intoCodeYourFuture:mainfrom
gai93003:Sprint-3-exercises
Closed

West Midlands | Gabriel Deng | Module-Structuring-and-Testing-Data | Sprint 3#207
gai93003 wants to merge 4 commits intoCodeYourFuture:mainfrom
gai93003:Sprint-3-exercises

Conversation

@gai93003
Copy link

@gai93003 gai93003 commented Nov 28, 2024

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with COHORT_NAME | FIRST_NAME LAST_NAME | REPO_NAME | WEEK
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Briefly explain your PR.

Questions

Ask any questions you have for your reviewer.

@gai93003 gai93003 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 28, 2024
@cjyuan cjyuan requested review from cjyuan and removed request for cjyuan December 2, 2024 00:46
@cjyuan
Copy link
Contributor

cjyuan commented Dec 2, 2024

You have modified files from Sprint-1 and Sprint-2 in your branch. Can you rebase your Sprint-3 branch to main so that the files in Sprint-1 and Sprint-2 remains the same as those in main?

@gai93003
Copy link
Author

gai93003 commented Dec 2, 2024 via email

@cjyuan
Copy link
Contributor

cjyuan commented Dec 3, 2024

Did you run git push --force origin Your_sprint_branch_name to force your local change onto remote repository after you rebased your sprint 3 branch? I can still see the changed files in sprint 1 and 2 folder in your sprint 3 branch. We can try to resolve this on Slack or over huddle if you can post a question or DM me on Slack.

@gai93003
Copy link
Author

gai93003 commented Dec 3, 2024 via email

Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left my comments in the code. If you need assistance on using Jest, please let me know or seek assistance from a volunteers.

return "Reflex angle";
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How value do you think the function should return when an angle < 0 and or > 360?

// console.assert(isProperFraction(-4, 7), `target output: false, Explanation: The fraction is not a proper fraction because the numerator is equal to the denominator. The function should return false.`);

console.assert(isProperFraction(-4, 7) === true, `target output: false, Explanation: The fraction is a proper fraction because the absolute value of the numerator (4) is less than the denominator (7). The function should return true.`);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In mathematics, -4/7 == 4/-7 and -4/-7 == 4/7.
So, ideally isProperFraction() should recognise all of them as proper fractions.

If you can calculate the absolute values of a the parameters first, you can possibly simplify your code.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added the absolute method to the function.

if (a + b <= c || a + c <= b || b + c <= a) {
return false;
}
else if (a <= 0 || b <= 0 || c <= 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to include the if-statement at lines 41-43?
Can you find any values for a, b, and c, such that the function will fail after you removed the if-statement at lines 41-43?
If you cannot find such a, b, and c, that means you probably do not need that if-statement.

I will not go into details why in some programming languages (but not JavaScript) we need also to ensure a, b, c are positives.

The main point I would like to make is, you should fully understand and be able to explain your code. An interviewer may ask you questions like what I am asking here, and it would reflect poorly on you if you cannot explain your code.

Also (a + b <= c || a + c <= b || b + c <= a) == !((a + b > c || a + c > b || b + c > a). These two conditions are opposite of each other. If you are interested in learning more about how to find the opposite of a condition, you can check out De Morgan's Law.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to fulfill the acceptance criteria
// scenario: invalid triangle
// Check for Valid Input:
// Given the sides a, b, and c,
// When any of the sides are less than or equal to zero,
// Then it should return false because a triangle cannot have zero or negative side lengths.

let lowerCaseLetters = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
let upperCaseLetters = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];

function rotateCharacter(char, num) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How should you deal with cases where num is a number like 100?
What if num can also be a negative number?

}
}

console.log(rotateCharacter("a", 3)); //Output: "d"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder what your function will return when it is called with the following parameters:

console.log(rotateCharacter("x", 3)); 
console.log(rotateCharacter("Y", 1));  

You can try making your function to work on lowercase letters first, and then duplicate your code with tiny modification to apply them to uppercase letters.

Also, try taking advantage of the % operator so that you don't to use any loop in your solution.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console.log(rotateCharacter("x", 3)); - returns 'A'
console.log(rotateCharacter("Y", 1)); - returns a

I will look into learning more the operator. Thanks for the recommendation.

*/
const isValidPass = require('./password-validator');

test("Is prime number", function(){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we testing prime number ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, i failed to change the description on the test.

test("Is prime number", function(){
expect(isValidPass('Calohh35#')).toBe(true);
expect(isValidPass('alohh35#')).toBe(false);
}); No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests does not check if the function can correctly return false for each specific type of invalid passwords.
For example, the test only check if the function can return false when a password does not contain any uppercase letter, but the test does not check if the function can return false when a password is missing a lowercase.

Can you include more test cases to see if the function can return false for each type of invalid passwords? They could possibly help you detect a bug in your code.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed out the digit checks in the regular expressions.

@@ -0,0 +1,5 @@
function repeat(str, count) {
return str.repeat(count);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the spec, what should happen if count is a negative number?

console.assert(getCardValue('A♠') === 11, 'The given value of "A" returns 11');
console.assert(getCardValue('8♠') === 8, 'The given value of 8♠ returns 8');
console.assert(getCardValue('J♠') === 10, 'The given value of J returns 10');
console.assert(getCardValue('Q♠') === 10, 'The given value of 2♠ returns 10'); No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you expect from the following function calls?
Does your function return the value you expected?

getCardValue("0Q♠");
getCardValue("010♠");
getCardValue("02♠");
getCardValue("0x02♠");
getCardValue("2.1♠")

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function will throw an error 'Invalid card rank since' since the above numbers doesn't match the numbers between 2 and 10. in a blackjack.

else if (cardValue === 'A') {
return 11;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you missed this description:

// Given a card with an invalid rank (neither a number nor a recognized face card),
// When the function is called with such a card,
// Then it should throw an error indicating "Invalid card rank."

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed 👀 Review Git Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Dec 7, 2024
@gai93003
Copy link
Author

gai93003 commented Dec 7, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants