Solved

Javascript question

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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

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…
This article discusses how to implement server side field validation and display customized error messages to the client.
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…
Suggested Courses

627 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