About Lesson
In this JavaScript lesson we are going to learn about JavaScript padStart() & padEnd(), so first let’s talk about padStart(), so padStart method pads a string with another string at the beginning, and it is a feature in JavaScript ES8.
Now let’s create an example in padStart, in here it will add d at the beginning of our text.
1 2 3 |
let name = "Parwiz"; console.log(name.padStart(10, 'd')); |
Let’s create an example on padEnd, so this method pads a string with another string at the end. in here it will add d at the end of our text.
1 2 |
let name = "Parwiz"; console.log(name.padEnd(10, 'd')); |