roberto-butti / some-drops-of-javascript

This book collects some useful, unknown, underrated JavaScript functions discovered and learned while using JavaScript daily.
https://drops-of-javascript.hi-folks.dev/
Other
151 stars 46 forks source link

New Functions for padding strings #22

Closed roberto-butti closed 1 year ago

roberto-butti commented 1 year ago

What

Add a new method documentation file for a new JavaScript function in src/content/docs. The instructions about defining the file's name are documented in the CONTRIBUTING.md file.

Description

Function name: padStart() and padEnd() Function description: ... File name: src/content/docs/05-string/02_str-padding.md

Checklist

Must read:

GriffinAnnshual commented 1 year ago

Hi @roberto-butti , I would like to work on this issue can you make me as assignee?

GriffinAnnshual commented 1 year ago

@roberto-butti could you please elaborate my task, the file and the documentation is written already it seems.

roberto-butti commented 1 year ago

Hi @GriffinAnnshual , Exactly i already created the file as a placeholder, especially for new contributors. As you can see in the naming of the file we are following an internal convention (src/content/docs/05-string/02_str-padding.md). So, in your case, you can explain the padStart() and padEnd() functions where you have the titles:

## Padding from the start of the string: `String.padStart()`

and

## Padding from the start of the string: `String.padEnd()`

Additional note: i see that padStart is useful for padding some numbers, so you can also add an example like this one:

let num = 15;
num.toString().padStart(32, '0');

Another thing to mention is that you can use a string (not just one single character) like this:

"hello".padStart(10,'-*');
GriffinAnnshual commented 1 year ago

Shall I add the examples in the "examples" directory?

GriffinAnnshual commented 1 year ago

Thank you @roberto-butti, I've made the PR.

roberto-butti commented 1 year ago

Yes, if you can and want. Otherwise, if you want to skip it, you can write a comment when you open a PR, i will create a new issue specifically for the example. Find the way that is most comfortable for you.

Roberto

roberto-butti commented 1 year ago

Thank you for the PR! I see you added also examples, great!

GriffinAnnshual commented 1 year ago

I am glad to have contributed to this project @roberto-butti, you're so receptive. Thank you so much.