Last active
September 24, 2018 20:40
-
-
Save colorful-tones/8356f9f82538501c948938b3a0ad1fed to your computer and use it in GitHub Desktop.
[Left pad] simple left page function from Wes Bos's ES6 course #JavaScript #utility
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://courses.wesbos.com/account/access/5b6921eb99ce1f5578c26a50/view/174357553 | |
function left_pad( str, length = 20 ) { | |
return `-> ${' '.repeat( length - str.length )}${str}; | |
} | |
console.log( left_pad( 'All' ); | |
console.log( left_pad( 'these' ); | |
console.log( left_pad( 'strings' ); | |
console.log( left_pad( 'should' ); | |
console.log( left_pad( 'be' ); | |
console.log( left_pad( 'right' ); | |
console.log( left_pad( 'justified' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment