/    Sign up×
Community /Pin to ProfileBookmark

Creating repeating characters

I was wondering if there is a way to create repeating characters such as periods or dashes to repeat after a word. This would create a look that is popular on menus.

Example

Hamburger……………….$3.00
Fries………………………$1.50
Steak and Eggs…………$6.50

to post a comment
CSS

3 Comments(s)

Copy linkTweet thisAlerts:
@scragarJan 08.2008 — [code=php]var message = "Hello";
message = message.pad(".", 10);
alert(message);[/code]
Copy linkTweet thisAlerts:
@cczerniaauthorJan 08.2008 — Thanks for the reply but I can't seem to get .pad to work. I tested in both IE and Firefox. In Firefox I get "message.pad is not a function"
Copy linkTweet thisAlerts:
@scragarJan 08.2008 — sorry, forgot to post the function ?
[code=php]String.prototype.pad = function(l, s, t){
return s || (s = " "), (l -= this.length) > 0 ? (s = new Array(Math.ceil(l / s.length) + 1).join(s)).substr(0, t = !t ? l : t == 1 ? 0 : Math.ceil(l / 2)) + this + s.substr(0, l - t) : this;
};[/code]
×

Success!

Help @cczernia spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...