7 Replies Latest reply on Jan 31, 2009 7:29 AM by kglad

    synchronizing multiple return statements?

    shintashi Level 1
      Earlier I was having difficulty with getting random numbers to appear in fraction form, and kglad and cbleech helped me out considerably. In the process of writing the fraction generator, I received a request to display the decimal version of the fractions (I know nothing about functions or C++) and modestly modified kglad's code as follows:

      -------- modified fraction/decimal code----------------
      function ranbot(x, m) {
      var d:Number = Math.ceil(Math.random()* x);
      var n:Number = Math.floor(Math.random()* d);
      if(m == 1){return n+ "/" + d;}
      if(m == 2){return n/d;}
      }
      ---------------------------------------------------------------------------

      there's a clear problem: the fractions and decimals don't match. (I honestly didn't think the decimal modification would work). Ideas?