Follow us on Twitter!
Your life is ending one minute at a time. If you were to die tomorrow, what would you do today?
Friday, April 18, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 30
Guests Online: 26
Members Online: 4

Registered Members: 82824
Newest Member: devilslegion
Latest Articles

Javscript Substrings

Arrow Image good help for js7



ok heres how javascript substrings work...
an example
< script language=\"JavaScript\">
var a1, a2, input;
a2=\"abcdefghij\";
a1=a2.substring (2,6)
input=prompt(\"Password:\",\"\");

if (input==a1) {

alert(\"correct you may enter\");

}

else {

alert:(\"wrong\");

}

}

< /script>

now to explain how it works
the first line just tells the server that we are using javascript now...
the 2nd line tells it that the variables a1 and a2 and for the input.
the 3rd line assigns abcdefghij to the variable a2.
the 4th line assigns the substring to a1.
the other lines just setup an input prompt, if you type in the correct answer which is store in a1 then you get through if not you get an error

-
The Substring Explanation
syntax:\'string\'.substring(non-inclusive,value.inclusive value)
therefor it basicly is
abcdefghij.substring(2,6);
now the abcdefghij is the string and the substring will want to take some info from it. It finds out what info it needs to get from the (2,6) it tells it to take the 3rd value from the string *notice it says 2 it\'s none inclusive* and it takes all the values up to 6 and that includes the 6th value *notice this time it is inclusive* so our variable will have the value:-
-CDEF-

Hope this helped

Comments

nights_shadowon September 27 2005 - 15:14:18
This is a nice article teaching substrings, but i would like to see Lucid_Dream (seeing as he's doing reverse code engineer articles) do a reverse code engineer on this kind of a script because it would be nice to have two different ways of accomplishing this javascript (and it would be a nice introductary lesson to reverse coding).
xJorDyxon September 27 2005 - 18:41:39
i made a slight mistake with the syntax it is: 'string'.substring(non-inclusive numeric value,inclusive numeric value) Wink
Xeroon September 28 2005 - 01:24:47
You can edit the article now if you make a mistake. See it at the top?
xJorDyxon October 01 2005 - 10:39:04
npe dont see anything about editing itFrown
nctrdgnon October 20 2005 - 23:33:57
how will we use + ? i mean s1.substring (6,9)+a2.substring
Zinyaon March 09 2006 - 12:04:44
the reason it is non-inclusive is because the first value is assigned 0
Post Comment

Sorry.

You must have completed the challenge Basic 1 and have 100 points or more, to be able to post.