Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Javascript question

Posted on 2007-11-20
4
Medium Priority
?
637 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
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…

722 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