Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    1
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question I would like to make an array containing operations I would like to be carried out.

    Is it possible to have one of nine elements of an array, each containing code that will fill in a square in a tic-tac-toe game, randomly chosen then the code executed?

    If not, can anyone explain why and/or another way to do it?

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,920
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Google is your friend!

  • Users who have thanked Philip M for this post:

    java n00b (01-02-2011)

  • #3
    Regular Coder
    Join Date
    Mar 2006
    Posts
    727
    Thanks
    35
    Thanked 132 Times in 123 Posts
    Tic tac toe shouldn't be too random...

  • #4
    Regular Coder
    Join Date
    Apr 2010
    Posts
    163
    Thanks
    3
    Thanked 25 Times in 25 Posts
    Code:
    x=["alert('hello world')","alert('goodbye world')"];
    eval(x[1])
    or
    Code:
    x=[function(){alert('hello world')},function(){alert('goodbye world')}]
    x[1]()


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •