Coding Challenge: Calculator
Discover what you can do with functions and try to implement a simple calculator that can perform all the basic arithmetic operations.
We'll cover the following
Problem statement
Complete the below program so that it offers the four basic arithmetical operations: addition, subtraction, multiplication and division. You can use either a function declaration or a function expression.
Input
calculate(4, "+", 6)
calculate(4, "-", 6)
calculate(2, "*", 0)
calculate(12, "/", 0)
Expected output
10
-2
0
Infinity
Coding exercise
Get hands-on with 1400+ tech skills courses.