Click to See Complete Forum and Search --> : Simplify the script??
Manju123
10-15-2003, 02:27 PM
HOw can i simplify the below script??
var x = Math.random();
//math.random returns number <1 and >=0
If (y>0.5) {
if ((y*2) < 1) {
y = 7;
} else {
y = Math.floor(y) + 1;
}
} else {
y = {Math.floor(y)*2) + 1;
}
Rgds,
manju
sciguyryan
10-15-2003, 02:34 PM
Why do you want to does it not work right?!
Manju123
10-15-2003, 02:44 PM
HI Ryan,
It works fine.. But can I simplify it MORE to fewer lines...???
Rgds
Manju
sciguyryan
10-15-2003, 03:01 PM
yes, like this:
if(y>0.5){if ((y*2)<1){ =7;}else{y=Math.floor(test)+1;}}else{y={Math.floor(test)*2)+1;}
that is exacly the same script, it will work exactly the same ann that has been done is to remove the spaces.
Manju123
10-15-2003, 03:26 PM
Thanx Ryan...
rgds
Manju
sciguyryan
10-16-2003, 09:46 AM
Thats ok, glad to help.
Just a bit puzzled here, you have
If (y>0.5) {
if ((y*2) < 1) {
if y is greater than 0.5 how can y*2 ever be less than 1
sciguyryan
10-18-2003, 06:09 AM
hmm, thats right? how does that work?