Expressions help

Discussion in 'HTML' started by mwh, May 5, 2005.

  1. mwh

    mwh Guest

    Hi.

    I am using Javascript to make a kind of calculator. I am trying to do
    addition, but when I use it, it just displays the numbers together, not
    added together. Example:
    function additionCalculator(num1, num2){
    var total = num1 + num2
    return total
    }

    I try to add the numbers, but it just puts them together.

    Also, I am trying to use subtraction and division, but I do not know
    how.

    Can anybody help?

    (____)
    (\/)
    /-------\/
    / | Mwh ||
    - ||----||
     
    mwh, May 5, 2005
    #1
    1. Advertising

  2. mwh

    Gazza Guest

    mwh mumbled the following on 05/05/2005 02:21:
    > Hi.
    >
    > I am using Javascript to make a kind of calculator. I am trying to do
    > addition, but when I use it, it just displays the numbers together, not
    > added together. Example:
    > function additionCalculator(num1, num2){
    > var total = num1 + num2
    > return total
    > }
    >
    > I try to add the numbers, but it just puts them together.
    >
    > Also, I am trying to use subtraction and division, but I do not know
    > how.
    >
    > Can anybody help?


    Amazing what you can find if you type in Javascript adding numbers into
    Google...
    http://homepage.ntlworld.com/kayseycarvey/variables4.html


    --
    Gazza
    Mobile Number Network Checker - http://mnnc.net/
    Creative writing & Poems - http://garyjones.co.uk/
    Leovanna Leonbergers - http://leovanna.co.uk/
     
    Gazza, May 5, 2005
    #2
    1. Advertising

  3. While the city slept, mwh () feverishly typed...

    > Hi.
    >
    > I am using Javascript to make a kind of calculator. I am trying to do
    > addition, but when I use it, it just displays the numbers together,
    > not added together.

    [...]

    From the FAQ's for the news:comp.lang.javascript newsgroup
    (http://www.jibbering.com/faq/), the following should help;

    4.21 Why does 1+1 equal 11? or How do I convert a string to a number?
    http://www.jibbering.com/faq/#FAQ4_21

    Hope that helps,
    Nige

    --
    Nigel Moss http://www.nigenet.org.uk
    Mail address will bounce. | Take the DOG. out!
    "Your mother ate my dog!", "Not all of him!"
     
    nice.guy.nige, May 5, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris R. Timmons

    Re: Help with regular expressions.

    Chris R. Timmons, Jul 4, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    411
    Chris R. Timmons
    Jul 4, 2003
  2. David Waz...

    Re: Help with regular expressions.

    David Waz..., Jul 4, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    399
    David Waz...
    Jul 4, 2003
  3. Stephajn Craig

    Regular Expressions....HELP!

    Stephajn Craig, Jul 16, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    3,044
    Cowboy \(Gregory A. Beamer\)
    Jul 16, 2003
  4. Jay Douglas
    Replies:
    0
    Views:
    638
    Jay Douglas
    Aug 15, 2003
  5. Noman Shapiro
    Replies:
    0
    Views:
    257
    Noman Shapiro
    Jul 17, 2013
Loading...

Share This Page