“Padend Javascript” Kode Jawaban

Padend Javascript

/* The padEnd() method pads the current string with a given string 
(repeated, if needed) so that the resulting string reaches a given length.
The padding is applied from the end of the current string. */

const str1 = 'Breaded Mushrooms';

console.log(str1.padEnd(25, '.'));
// expected output: "Breaded Mushrooms........"

const str2 = '200';

console.log(str2.padEnd(5));
// expected output: "200  "
Mehedi Islam Ripon

String Padstart Padend

let string = ‘Alice’; 
// padStart() — we assume our string needs to have 10 characters 
string.padStart(10, ‘o’); // returns ‘oooooAlice’
// padEnd() 
string.padEnd(10, ‘o’); // returns ‘Aliceooooo’;
Creepy Gábor

Padend Javascript

const str1 = '123';
str1.padEnd(3, '0');  // "12300"
str1.padEnd(3, '*'); // "123**"
Tiny Coders

Jawaban yang mirip dengan “Padend Javascript”

Pertanyaan yang mirip dengan “Padend Javascript”

Lebih banyak jawaban terkait untuk “Padend Javascript” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya