NW6 | Fathi_Kahin | Module-JS1 | Week4#176
NW6 | Fathi_Kahin | Module-JS1 | Week4#176fhkahin wants to merge 46 commits intoCodeYourFuture:mainfrom
Conversation
musayuksel
left a comment
There was a problem hiding this comment.
Great job, @fhkahin ! Your week-4 solutions were excellent. Well-structured, thorough, and impressive attention to detail. If you have any questions, feel free to reach out.
| // This is a function that will validate the credit card number | ||
| function isCreditCardValid(cardNumber) { | ||
| // Here we are checking if the card number is a string; if not, we are converting it to a string | ||
| let cleanedCardNumber = (typeof cardNumber === 'string') ? cardNumber.replace(/[^0-9]/g, '') : ''; |
There was a problem hiding this comment.
To convert to sting, you can use the toString method.
| cleanedCardNumber.length === 16 && | ||
| hasAtLeastTwoDifferentDigits(cleanedCardNumber) && | ||
| isFinalDigitEven(cleanedCardNumber) && | ||
| isSumGreaterThan16(cleanedCardNumber) |
There was a problem hiding this comment.
Wow, I must say, I'm really impressed with the way you tackled the problem! The idea of breaking it down into small functions for each part is simply brilliant. Keep up the great work!
| const inputString = "aaaaaaa"; | ||
| const targetChar = "a"; | ||
| const currentOutput = countChar(inputString, targetChar); |
There was a problem hiding this comment.
You true master of readable code and & know the meaning of readable code. Well done @fhkahin
| return false; // 0 and 1 are not prime numbers | ||
| } | ||
|
|
||
| for (let i = 2; i <= Math.sqrt(num); i++) { |
There was a problem hiding this comment.
This is completely true. As a further improvement, create a variable for Math.sqrt(num) to improve readability. (Like you did before)
|
|
||
|
|
||
| function isPasswordValid(password, previousPasswords = []) { | ||
| if (password.length < 5) { |
There was a problem hiding this comment.
This task can be broken down into smaller steps by creating individual functions. You seem to be familiar with this approach :) ex:
isPasswordLongerThenFiveDigits(password) and so on so forth
| //............................................ | ||
| //Answer | ||
|
|
||
| function repeat(str, count) { |
Learners, PR Template
Self checklist
Changelist
Briefly explain your PR.
This is JS1 module, Week 4 exercises (completed)
Questions
Ask any questions you have for your reviewer.