-
-
Notifications
You must be signed in to change notification settings - Fork 50
NW-6 | Zeliha Pala | JS1| [TECH ED] Complete week 4 exercises | WEEK-4 #188
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.
Good work Zeliha! Ive just left some comments for a few sections, you can have a look.
for (let i = 0; i < str.length; i++) { | ||
if (str[i] === char) { | ||
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.
A good solution for the count. Also its better to keep clean code removing comment out lines. 👍
week-4/implement/count.test.js
Outdated
return count; | ||
} | ||
//const stringInput = "Harry Potter and the Philosopher's Stone"; stringInput gives a redeclaration error in here. I cleared it and still working | ||
test("countChar - character 'e'", () => { |
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.
test description part needs to be more specific explanation such as "works for multiple char occurrences" or "works for no char occurrences"
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.
@RbAvci Thank you for your review. You are right. I'll provide the explanations as you suggested.
|
||
function getOrdinalNumber() { | ||
return "1st"; | ||
} |
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.
The getOrdinalNumber function always returns "1st" regardless of the input. If you want the function to generate ordinal numbers based on the input dynamically, you must modify the function.
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.
Thank you @RbAvci that was so helpful I worked on this exercise and fixed. Now test cases are working
return "1st"; | ||
} | ||
|
||
test("converts 1 to an ordinal number", function () { |
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.
Also, you can write tests for numbers "2nd" and "3rd". In that way, you can fill in the logic inside the getOrdinalNumber function.
} | ||
|
||
return true; | ||
} |
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 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.
It's awesome job, @zelihapala !
I only left one comment with the hint for the possible optimisation. But you really did a great job here! 🥇
} else if (count === 0) { | ||
return ""; | ||
} else if (count === 1) { | ||
return str; | ||
} else { | ||
return str.repeat(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.
Do we really need to check 0
and 1
values? What would happen if we called str.repeat(0)
or str.repeat(1)
?
Learners, PR Template
Self checklist
Changelist
Briefly explain your PR.
Questions
Ask any questions you have for your reviewer.