Giter Site home page Giter Site logo

function-practice's Introduction

function-practice

cf201 lab for march 18, 2016

This repo contains an index.html and an app.js which allows for the following functions to be run through the developer console when viewing index.html in your browser. Detailed descriptions of each function are below.

  • sum()
  • multiply()
  • sumAndMultiply()
  • sumArray()
  • multiplyArray()

Functions available

###sum(n1,n2) sum() takes two numbers, n1 and n2, as parameters and returns the summed total of both. Note that this function was modified for sumAndMultiply - console.log for this function is commented out.

Example: sum(4,7) will console.log "The sum of 4 and 7 is 11."

###multiply(n1,n2) multiply() takes two numbers, n1 and n2, as parameters, and returns the multiplied total (the product) of both. Note that this function was modified for sumAndMultiply - console.log for this function is commented out.

Example: multiply(4,7) will console.log "The product of 4 and 7 is 28."

###sumAndMultiply(n1,n2,n3) sumAndMultiply() takes three numbers, (n1, n2, n3) as parameters, and returns both the sum of all three and the product of all three in an array, sumAndMultiplyArray. It will also console.log both the sum and the product.

Example: sumAndMultiply(4,5,6) will console.log "4 and 5 and 6 sum to 15." and "The numbers 4 and 5 and 6 have a product of 120." as well as returning an array consisting of [sum, product] - e.g. [15, 120]

###sumArray([n1,n2, ... nX]) sumArray() takes a single array of numbers as a parameter and console.tables the array, adds the values of each index in the array together, and reports the summed total via console.log.

Example: sumArray([1,2,3,4,5]) will return a console.table of [1,2,3,4,5] as well as console.logging "1,2,3,4,5 was passed in as an array of numbers and 15 is their sum."

###multiplyArray([n1, n2, ... nX]) multiplyArray() takes a single array of numbers as a parameter and console.tables the array, and then console.logs the product of the values in the array.

Example: multiplyArray([2,3,4,5]) will return a console.table of [2,3,4,5] as well as console.logging "The numbers 2,3,4 have a product of 24."

function-practice's People

Contributors

peterbreen avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.