I would like to propose an improvement to the exemplar solution for the “Poetry Club Door Policy” exercise. More specifically, its implementation of backDoorResponse. Right now it is:
I kind of understand the point you’re making, however there are things to consider:
This is a learning exercise, aimed at teaching specifically the .length property, string indexing and working with strings helper methods. Changing the “exemplar” solution would probably necesitate changing the whole exercise to include an explanation, so it’s not that simple. We should consider if there’s merit to it.
Also, using .at(-1) might be a very succinct way of doing it (there’s a reason why it’s made its way from python to other languages) but it kind of obfuscates the length so if you’re not sure how it works and if it’s not explained, it can feel as “black magic”.
Personally, whenever I see a solution using .at(-1) or .slice(-1) i would tend to approve it (assuming everything else is okay) with a note saying this isn’t the intended way to solve this exercise, but is a good way nonetheless.
That makes sense. If you haven’t seen a negative index syntax before, it would definitely be confusing, so it’s probably better to let people get accustomed to .length before introducing .at as an alternative for these kinds of cases.
Would it be worth mentioning trimStart/trimEnd along with trim?
The approaches in the Dig Deeper tab and the Exercise notes in the mentor guidance tab, right? I haven’t contributed to either before, but I do know about them.
I suspect mentioning multiple trim* methods in the mentoring note might not have a huge amount of value. The audience is small and the mentors probably already know there are multiple trim methods. Approach docs have a much larger audience and tends to have higher value.
So there could be an approach using trim and another using trimEnd ? If it’s just a difference of three characters, discussing it in the Dig Deeper introduction notes instead would make more sense. Maybe it could discuss possible tradeoffs (shortness vs performance)? Or maybe have both approaches & intro notes?
Normally we’d ask people to discuss the proposed content here, but since we do not have any approaches for this exercise yet, I am cool if you create a PR and we discuss there.
I would consider:
For getting rid of the whitespace the difference between trim vs trimEnd / trimStart vs replace / replaceAll
For last character the differences between [index] access vs at vs charAt vs subString vs slice(-1)
To uppercase the difference between toLocaleUpperCase vs toUpperCase vs String.fromCharCode(charCodeAt(0) - 32)
There are probably more approaches to be thought of, feel free to include as much or as little as you like. If you only want to tackle the trim + at stuff, that’s fine. Then we’ll write the rest.
I looked through the links and I think I have some idea of how to go about creating the approach now. However, I have a question: how do you generate the unique uuid?
@SleeplessByte do you know how I can get the javascript / format / verify check to pass on introduction.md? It says “Code style issues found in the above file. Run Prettier with --write to fix.” Any help would be appreciated.