...

View Full Version : question about writing a java script



agater
11-10-2010, 01:44 AM
hey guys "

I have question about writing a java script code equivalent to the following figure :

http://www.almlf.com/get-10-2010-almlf_com_h59hz9rg.png (http://www.almlf.com/)


I've written the code like this ,


<html>
<body>

<script type="text/javascript">
var x;

x = 12;

while (x != 0)
{
document.write(" x = " + x +"<BR>");
x = x - 3;

}
document.write("DONE");

</script>

</body>
</html>


is my answer right or wrong ?? <

Old Pedant
11-10-2010, 02:01 AM
Looks fine to me.

Now what about if the first instruction was "set number to 13".

What is then wrong with the flow chart? What is then wrong with the code?

Oh...one VERY minor point.

You *CAN* write

x = x - 3;
as

x =- 3;

Don't change your code. Just FYI.

Hmmm....*technically* you are doing too much.

The instruction says "write out the value of the number...".

You are writing "x =" in addition to that. <grin/>

Dormilich
11-10-2010, 09:57 AM
x =- 3;


x -= 3;

agater
11-10-2010, 01:44 PM
Looks fine to me.

Now what about if the first instruction was "set number to 13".

What is then wrong with the flow chart? What is then wrong with the code?

Oh...one VERY minor point.

You *CAN* write

x = x - 3;
as

x =- 3;
Don't change your code. Just FYI.

Hmmm....*technically* you are doing too much.

The instruction says "write out the value of the number...".

You are writing "x =" in addition to that. <grin/>


thanks man , :thumbsup:
I am going to practice more on the question.

Old Pedant
11-10-2010, 08:38 PM
x -= 3;

Dyslexia strikes again.

(Actually, it's just that my fingers get ahead of my vision/brain at times. I so often type "hte" and "thsi" that it's scary. And as I was typing this I tried to put in "tyep"...sigh.)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum