Solved

Javascript question

Posted on 2007-11-20
4
625 Views
Last Modified: 2008-02-01
My son asked for help and I can't help him...
any ideas???

ROFL...I KNOW it frightens you that my offspring is learning this too...lol

var foo = 5 + 6 * 7
var bar = foo % 8
var moo = bar * 2
var rar = moo / 3
function check(x)
{
        if (x.length == moo)
        {
                        alert("win!");
                        window.location += "?lvl_password="+x;
        } else {
                        alert("fail D:");
     }
}
0
Comment
Question by:tsmithinnc
4 Comments
 
LVL 7

Expert Comment

by:bdichiara
ID: 20323809
You'll have to be more specific. What is the objective here? What does this do? What do you need help with? Do you need an explanation as to what's going on here?
0
 
LVL 25

Expert Comment

by:imitchie
ID: 20323836
var foo = 5 + 6 * 7;
var bar = foo % 8;
var moo = bar * 2;
var rar = moo / 3;
function check(x)
{
        if (x.length == moo)
        {
                        alert("win!");
                        window.location += "?lvl_password="+x;
        } else {
                        alert("fail D:");
     }
}

you need ; after every statement?
0
 

Author Comment

by:tsmithinnc
ID: 20323875
I have no idea what it is doing...he says it is giving him 14, but ...
I told him the function is saying if the length of x is 14 then he will get a prompt saying win...
otherwise fail...

is that right???
0
 
LVL 2

Accepted Solution

by:
yossi_intlock earned 500 total points
ID: 20324160
this code, in generaly, intent to check a realy simple password.
its a game - if you guess the password that you win else you loose.
ive added a simple application that can show it in an html page
its quit simple - if you enter the right length value than you win else you loose.
copy the code (its your code with some user interface addin) to notepad than  save it as HTML file on your desktop.
open the file (dbl click) and try to find out what is the password :-)
the answer is: any input that its characters length is exactly 14 (thats the value of 'moo' variable).
good luck!
<HTML>
	<HEAD>
	<SCRIPT>
		
var foo = 5 + 6 * 7 
var bar = foo % 8
var moo = bar * 2
var rar = moo / 3
function check(x)
{
        if (x.length == moo)
        {
                        alert("win!");
                        window.location += "?lvl_password="+x;
        } else {
                        alert("fail D:");
     }
}
function preCheck(){
	var input = document.getElementById('password').value;
	if(input == "")alert('please type your password');
	check(input);
}
 
	</SCRIPT>
	</HEAD>
	<BODY>
	<br/>
	password here: <input type="text" id="password"/>
	<br/>
	<input type="button" onclick="preCheck()" value="check your password level !"/>
	</BODY>
</HTML>

Open in new window

0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question