What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [beta UPDATE] Math Games

[beta UPDATE] Math Games
Author: Message:
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [beta release] Math Games
quote:
Originally posted by roflmao456
sometimes returns undefined in the message.
example : when doing 1+1 it sometimes (rarely) returns 1undefined1..
hope someone can fix..?
BEDMAS
Brackets Exponents Division Muliplication Addition Subtraction.

code:
randomop=Math.round(Math.random()*(op.length)-1);

The order of the code that would be processed first is as follows
code:
randomop=Math.round(Math.random()*(op.length)-1);
                    |              |________| |
                    |                   |   | |
                    |                   |_ processed first
                    |_______________________| |
                    |            |            |
                    |            |_ processed second
                    |                         |
                    |                         |
                    |_________________________|
                                 |
                                 |_ processed third

So with your code if the random number generated is 0 then once you subtract 1 you end up with -1 as a value and there is no operator at array position -1.

code:
randomop=Math.round(Math.random()*(op.length-1));

Is the right code.

This post was edited on 11-27-2006 at 11:57 PM by matty.
11-27-2006 11:47 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
[beta UPDATE] Math Games - by roflmao456 on 11-27-2006 at 11:24 PM
RE: [beta release] Math Games - by matty on 11-27-2006 at 11:47 PM
RE: [beta release] Math Games - by roflmao456 on 11-28-2006 at 12:42 AM
RE: [beta release] Math Games - by dylan! on 11-28-2006 at 12:44 AM
RE: [beta release] Math Games - by matty on 11-28-2006 at 02:38 AM
RE: RE: [beta release] Math Games - by roflmao456 on 11-28-2006 at 04:04 AM
RE: [beta release] Math Games - by matty on 11-28-2006 at 04:09 AM
RE: [beta release] Math Games - by roflmao456 on 11-28-2006 at 04:15 AM
RE: [beta UPDATE] Math Games - by elektra on 11-28-2006 at 04:49 PM
RE: RE: [beta UPDATE] Math Games - by roflmao456 on 11-28-2006 at 08:56 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On