|
|
 |
|
|
Pages: 1
JS Help!
(Click here to view the original thread with full colors/images)
Posted by: Yakbak
Wheee!
I need help with some mathematical and varable JS code. Since I can't upload files, I'll just read out the source code. NOTE that the "Document.Challenger.solution.value" is the value to be submitted in a form in the whole HTML page, but I'm only posting the JS code:
Code:
<script language="javascript">
<!--
function Changling(nummer) {
return (nummer*1);
}
function Changling2(str1, str2) {
var num = str1 + str2;
var num2 = eval(num);
num2 = num2 + 2;
return num2;
}
function checkIT() {
var num = document.Challenger.solution.value + 1;
num = (num * 3);
num = Changling(num);
var num2 = Changling2("73630","6291");
if (num == num2)
{
return true;
}
else
{
alert('Incorrect.');
return false;
}
}
-->
</script>
The objective is to find the document.Challenger.solution.value.
Help! 
[ March 25, 2001: Message edited by: Yakbak ]
Posted by: Scav
Guys I've already looked at it with yak and I dunno the whole thing but i think this does the whole thing very much cleaner and the answer is 26640. Thats just me though and if i had my way i would totaly remove all the little math things and just have it be a straight if/else statement comparing the input number to the one you want. But im guessing you have it like that to throw off people who cannot read javascript?
This was tested on netscape and ie and seems to work, i did change the form name to lowercase challenger though, nicer than random upper case letters 8P.
It's kinda funky looking code, my ownly guess is the creator tried to make it as confusing as possible so people couldnt look at it and figure out what the answer is. like for example the changling function that doesnt change the number in any way...
<script language="javascript">
var num;
var num2;
function calculate()
{
num = document.challenger.solution.value;
num = eval(num);
num++;
num = num * 3;
num2 = 73630 + 6291;
num2 = num2 + 2;
if (num == num2)
{
return true;
}
else
{
alert("Incorrect");
return false;
}
}
</script>
Posted by: Scav
n/m it appears the point of that script was to be buggy.
Posted by: Yakbak
Damn you are good Scav...
|
|
|
|
|