Please login or register. Welcome to the Studio, guest!


Quick Links:


newBookmarkLockedFalling

crazynarutard

crazynarutard Avatar

*****
Senior Studio Member

1,470


August 2005
My first try at prototype, so don't make me feel bad :(

<script type="text/javascript">

var string = "Hello World!"

String.prototype.reverse = function(){
   for( a = this.length ; a > -1 ; a -- ){
      var New = this.charAt(a);
      document.write(New);
   }
}
string.reverse()

</script>



Chris

Chris Avatar

******
Head Coder

19,519


June 2005
:P BEtter then I can do Crazy.

Also, I don't see where this would be used, but it could be fun to mess with.

crazynarutard

crazynarutard Avatar

*****
Senior Studio Member

1,470


August 2005
cddude229 said:
:P BEtter then I can do Crazy.

Also, I don't see where this would be used, but it could be fun to mess with.

It's open source so..people can um..study it :P

crazynarutard

crazynarutard Avatar

*****
Senior Studio Member

1,470


August 2005
Here's another way to do it.

<script type="text/javascript">

var nMessage = '';
var Container = [];
String.prototype.strReverse = function()
{
   for( z = 0 ; z < this.length ; z ++ )
      Container.push( this[z] );
   Container.reverse();
   for( x = 0 ; x < Container.length ; x ++ )
      nMessage += Container[x]
   return nMessage;
}

var Message = "Hello World!";
document.write( Message.strReverse() );

</script>


Chris

Chris Avatar

******
Head Coder

19,519


June 2005

String.prototype.strReverse = function()
{
var nMessage = '';
var Container = [];
for( z = 0 ; z < this.length ; z ++ )
Container.push( this[z] );
Container.reverse();
for( x = 0 ; x < Container.length ; x ++ )
nMessage += Container[x]
return nMessage;
}

var Message = "Hello World!";
document.write( Message.strReverse() );


That'd probably be more effective, because if you used it twice, it may give an error in some browsers (thought it shouldn't, because you're using them in functions)

newBookmarkLockedFalling