scotandz's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
Members
Active Posts:
27 (0.01 per day)
Joined:
04-May 10
Profile Views:
946
Last Active:
User is offline Dec 07 2014 02:28 PM
Currently:
Offline

Previous Fields

Country:
Who Cares
OS Preference:
Windows
Favorite Browser:
Internet Explorer
Favorite Processor:
Intel
Favorite Gaming Platform:
XBox
Your Car:
Who Cares
Dream Kudos:
0

Latest Visitors

Icon   scotandz has not set their status

Posts I've Made

  1. In Topic: Adding 2 numbers using 3 functions

    Posted 30 Jul 2013

    got it working used if statement as opposed to switch though

    function num1()
    {
        var randomNumber1 = Math.floor((Math.random()*10)+1)
        return randomNumber1;
    }
    function num2()
    {
        var randomNumber2 = Math.floor((Math.random()*10)+1)
        return randomNumber2;
    }
    function randomMath()
    {
        var randomMath = Math.floor((Math.random()*4)+1)
        return randomMath;
    }
    function sum()
    {
        var math = randomMath();
        var n1 = parseInt(num1());
        var n2 = parseInt(num2());
        var total;
        if (math == "1")
        {
            total= n1 + n2;
        }
        if (math == "2")
        {
            total= n1 - n2;
        }
        if (math == "3")
        {
            total= n1 * n2;
        }
        if (math == "4")
        {
            total= n1 / n2;
        }
    
    //alerts to check the calculation was correct 
        alert(n1);
        alert(math);
        alert(n2);
    
    
        alert(total);
    
    
    
    


    Next task is to remove those pointless 3 functions and change if to switch. thanks all
  2. In Topic: Adding 2 numbers using 3 functions

    Posted 30 Jul 2013

    Yea thanks im in the process of trying your suggestion think i was getting a bit ahead of myself hoping it would some how know its a mathematical sign in the variable ill post my results
  3. In Topic: Adding 2 numbers using 3 functions

    Posted 30 Jul 2013

    Hi

    Basically im just learning javascript and i decided to make a small program that would generate 2 number randomly and a mathematical sign randomly and ask the use to input the answer if correct the user is the winner if not they are the loser i created 3 functions 2 of which returns a randomized number the other returns a randomized mathematical symbol i want to use the 3 functions to get the total so for example function1 = 10 function 2 = - function3 = 5 would give a total of 5

    var total = 10 - 5;

    what im looking for is

    var total function1() function2() function3();

    function num1()
    {
        var randomNumber1 = Math.floor((Math.random()*10)+1)
        return randomNumber1;
    }
    function num2()
    {
        var randomNumber2 = Math.floor((Math.random()*10)+1)
        return randomNumber2;
    }
    function randomMath()
    {
        var text = "";
        var possible = "/+-*";
    
        for( var i=0; i < 4; i++ )
            text += possible.charAt(Math.floor(Math.random() * possible.length));
        return text.substring(3);
    }
    function sum()
    {
        var total = num1()','randomMath()','num2();
    }
    
    
    

My Information

Member Title:
New D.I.C Head
Age:
26 years old
Birthday:
January 14, 1989
Gender:
Years Programming:
2
Programming Languages:
C#
Vb.net

Contact Information

E-mail:
Private

Friends

scotandz hasn't added any friends yet.

Comments

scotandz has no profile comments yet. Why not say hello?