Welcome to MoiK78 blog. Your daily intake of Internet news. This is a personal site so I post whenever I can :) but I'll try to get it daily. Be free to email me any suggestion. El bolg de Moisés García sobre tecnologías de internet y programas de diseño.
Homepage About Me Contact Me Buy at MoiK78 online shop Downloads

Welcome to MoiK78 blog, your daily intake of internet and technology news.

Picasa Web Albums My Picasa Photo Albums / Albumes de Fotos

November 06, 2002

New methods for the String object.
Today I'm going to start including some of the functions I have created for my daily work and I think they will help you.
The first one outputs the string in reverse order without modifing the original.
String.prototype.Reverse = function(){
var temp;
for (var z=this.length-1;z>-1;--z) {
temp+=this.charAt(z);
}
return temp;
}

Usage:
myString = new String("example");
reverseString = myString.Reverse();
trace (reverseString); => "elpmaxe"


This one checks if the string has Spanish characters like , , , etc..
We have to include two arrays containing the letters:
var lowercase = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n",
"","o","p","q","r","s","t","u","v","w","x","y","z","","","","",""];
var uppercase= ["A","B","C","D","E","F","G","H","I","J","K","L","M","N",
"","O","P","Q","R","S","T","U","V","W","X","Y","Z","","","","",""];
String.prototype.SpanishLetter = function(){
var letter = this.toString();
for (var i = 0; i < lowercase.length; i++) {
if (letter == lowercase[i] || letter == uppercase[i]) {
return true;
}
}
return false;
}

Usage:
myString = new String("");
if (myString.SpanishLetter()) {
trace("Spanish letter");
} else {
trace("Not Spanish letter");
}

Well I think that's all for today, tomorrow more...


 
Site Meter