Solved

Javascript question

Posted on 2007-11-20
4
621 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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. …
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…

746 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now