|
Q936 How can a function return true first time, then false, then true....?
irt.org | Knowledge Base | JavaScript | Function | Q936 [ previous next ]
Q936 How can a function return true first time, then false, then true....?
Try:
<script language="JavaScript"><!--
var bool=false;
function not() { return (bool = !bool); }
alert(not());
alert(not());
alert(not());
alert(not());
//--></script>
|
Although you don't really need a function for this, just:
<script language="JavaScript"><!--
var bool=false;
alert(bool = !bool);
alert(bool = !bool);
alert(bool = !bool);
alert(bool = !bool);
//--></script>
|
|
|
Copyright © 1996-2008 irt.org, All Rights Reserved.