Join us at IRC!
Never in the field of human conflict was so much owed by so many to so few. - Winston Churchill
Thursday, May 24, 2012
Navigation
Members Online
Total Online: 32
Web Spiders: 13
Guests Online: 27
Members Online: 5

Registered Members: 70200
Newest Member: ScubaSteve
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

looping letters in javascript

ranma
Member



Posts: 269
Location: Behind a sphere
Joined: 27.08.05
Rank:
HBH Guru
Posted on 22-04-06 02:54
how do you loop letters in javascblockedript?
Author

RE: looping letters in javascript

HopelessRomantic
Member

Posts: 71
Location: Lost in my own cryptic thoughts.
Joined: 14.04.06
Rank:
Uber Elite
Posted on 22-04-06 02:57
I don't know personally but check out http://www.w3schools.com they might have something about that.



"Judge not by age but by maturity"
blasphemy-fd@hotmail.com
Author

RE: looping letters in javascript

Jake
Member

Posts: 107
Location: United States
Joined: 13.12.04
Rank:
God
Posted on 23-04-06 15:08
What do you mean exactly?

Like:

<scblockedript>
for( i = 0; i <= 10; i++ )
document.write('a');
</scblockedript>


?


Author

RE: looping letters in javascript

wolfmankurd
Member



Posts: 1519
Location: UK
Joined: 30.05.05
Rank:
God
Posted on 23-04-06 15:12
doesnt that write i 10 times? i think he means without the increment


BY READING MY POST, YOU ACCEPT IT AS IS AND AGREE TO MY DISCLAIMER OF ALL WARRANTIES, EXPRESS OR IMPLIED, AS WELL AS DISCLAIMERS OF ALL LIABILITY, DIRECT, INDIRECT, CONSEQUENTIAL OR INCIDENTAL, THAT MAY ARISE FROM THE USE OF THIS (MIS)INFORMATION.


Widowmakr@hotmail.com http://LetsHackStuff.com
Author

RE: looping letters in javascript

BobbyB
Member



Posts: 260
Location: England
Joined: 16.03.05
Rank:
Monster
Posted on 23-04-06 15:36
I'm not quite sure, but I think he wants to loop through different letters. There would be a couple of ways to do this, one would be to use a String.fromCharCode(int) function in a for loop.

String.fromCharCode(i) returns the character of the ascii value of i;

For example, String.fromCharCode(65) returns a capital A.

Stick this in a for loop, like so:

<scblockedript>
for (x = 65; x <= 81; x++)
{
document.write(String.fromCharCode(x));
}
</scblockedript>


This would print every character from capital A to capital Q.

Another way to do it would be to make a string of all the characters you wish to loop through, then loop through every character in the String.charAt(int) method. This returns the character that is number int in the string, for example

<scblockedript>
var chocka = "absdfty152634k";
for (i = 0; i < chocka.length; i++)
{
document.write(chocka.charAt(i));
}
</scblockedript>


This loops through every character in the string Chocka and prints them.




Edited by BobbyB on 23-04-06 15:43
Guest
Username

Password

Remember Me


Bookmark This Page
Affiliates
Adverts

 

 

Links
By using, viewing or obtaining any information contained on this site, you agree to the disclaimer.

© HellBound Hackers 2008- 2009. Since 3rd December 2004.