1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

problem with numbers

Discussion in 'JavaScript' started by ssimon171078, May 20, 2015.

  1. #1
    i write in javascript :3 random numbers i want that i can sum 3 number and receive sum of 100
    how can i fix algorithm,problem that i can not receive sum of 100 (number1+number2+number3)=100:
    var number1=(Math.floor(Math.random() * 50) + 1);
    var number2=(Math.floor(Math.random() * 25) + 1);
    var number3= 100-(number1+number2);
    var num=new Array(number1,number2,number3);
     
    ssimon171078, May 20, 2015 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #2
    Could you repeat the question in ENGLISH? It looks like what you are asking for is provided by that math, but your sentences aren't exactly clear on that.

    That said, stop saying VAR on every blasted line, you can comma delimit those.
     
    deathshadow, May 20, 2015 IP