Skip to content

Latest commit

 

History

History
27 lines (19 loc) · 736 Bytes

js.md

File metadata and controls

27 lines (19 loc) · 736 Bytes

Functions

Homework Due Wednesday, March 7 at noon.

For this assignment, you should create a javascript function that is a simple calculator. The function should take three arguments (i.e., inputs):

  • num1 - a number
  • num2 - another number
  • operator - +,-,*,/ (the math operation to be performed)

For help with this, take a look at our class notes http://jsbin.com/doquji/edit?js,console, lines 57-60 and lines 46-50 in particular.

Some hints:

  • All of your logic should be contained inside your function
  • Inside your function, you will likely have four "if" statements
  • The only code that should be outside of your function is the statement which calls it, e.g,:
    console.log(calc(1,2,'*');

Good luck!