Technology Programming

How to Return Addition Functions for Multiple Numbers in JavaScript

    • 1). Launch the standard, plain-text editor application that is available on your computer.

    • 2). Enter the following code into the text editor:

      <html>

      <body>

      <h1>Calculate Standard deviation</h1>

      <script type="application/javascript" >

      var stats=new Array()

      function calcstats(a,b,c,d,e,f) {

      var sumdev=0;

      var standardev=0;

      var results=new Array()

      // averaging the numbers

      var mean=(a+b+c+d+e+f)/6;

      // subtracting the each number from the mean and squaring the difference

      sumdev=sumdev+Math.pow((mean-a),2);

      sumdev=sumdev+Math.pow((mean-b),2);

      sumdev=sumdev+Math.pow((mean-c),2);

      sumdev=sumdev+Math.pow((mean-d),2);

      sumdev=sumdev+Math.pow((mean-e),2);

      sumdev=sumdev+Math.pow((mean-f),2);

      // dividing the result by the degrees of freedom

      standardev=Math.sqrt(sumdev/5);

      // storing the results in the array

      results[0]=mean;

      results[1]=standardev;

      // returning the array

      return results;

      }

      // function call to get average

      // and storing the results in the array, stats

      stats = calcstats(1, 5, 4, 6, 10, 18);

      document.write ("The average is is " + stats[0]);

      document.write ("");

      document.write ("The Standard Deviation is +- " + stats[1]);

      </script>

      </body>

      </html>

    • 3). Click the "File" menu. Select the "Save" option. Save under the file name, "test.html."

    • 4). Launch the web browser that is available on your computer. Click on the "File" menu item and select "Open File."

    • 5). Locate the file "test.html" just created, select it with the mouse and then click on "Open."

    • 6). Your browser should display:

      The average is is 7.333333333333333

      The Standard Deviation is +- 5.988878581726855

SHARE
RELATED POSTS on "Technology"
WordPress - How to Set up a New Theme to WordPress 3.
WordPress - How to Set up a New Theme to WordPress 3.
Solution of Creative Web Design
Solution of Creative Web Design
The three disciplines of User Experience
The three disciplines of User Experience
Web Design Sheffield Options For Professional Enterprises
Web Design Sheffield Options For Professional Enterprises
Do you have what it takes?
Do you have what it takes?
Segway Cost
Segway Cost
Microsoft Access 2010: What's Coming with Office 2010?
Microsoft Access 2010: What's Coming with Office 2010?
Companies of Web Development in Ireland Provide Designs that Work
Companies of Web Development in Ireland Provide Designs that Work
Penguin Update to Put Red-Flags on Negative SEO
Penguin Update to Put Red-Flags on Negative SEO
Innovative web 2 design templates can make your business famous quickly
Innovative web 2 design templates can make your business famous quickly
Building A Search Engine Friendly Website
Building A Search Engine Friendly Website
Exceptional Advice To Build Up Your Internet Marketing
Exceptional Advice To Build Up Your Internet Marketing
The Benefits of Selecting The Right Hosting Company
The Benefits of Selecting The Right Hosting Company
Is There a Methodology for Making Successful Logos
Is There a Methodology for Making Successful Logos
Benefits of Ruby On Rails Development
Benefits of Ruby On Rails Development
The Power of Colour and Shapes in Your Infant's Life.
The Power of Colour and Shapes in Your Infant's Life.
Advantages of Hiring PSD To HTML Service Providers
Advantages of Hiring PSD To HTML Service Providers
How to Make Responsive Web Design Attractive?
How to Make Responsive Web Design Attractive?
Converting PSD to Responsive HTML
Converting PSD to Responsive HTML
Just a few realy really hints and tips when it comes to website design but look for.
Just a few realy really hints and tips when it comes to website design but look for.

Leave Your Reply

*