Created
December 20, 2021 20:18
-
-
Save theterminalguy/8a78751034355e97a247b7e816f41fe8 to your computer and use it in GitHub Desktop.
Live Coding
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Write a function that takes an object. The object contains a left, right and operator properties. The left and right properties are numbers. The operator property is a string. The function should return the result of the operation. The function should return null if the operator is not one of the following: +, -, *, /. | |
// Example: | |
// calculate({ left: 1, right: 2, operator: '+' }) // 3 | |
// calculate({ left: 1, right: 2, operator: '-' }) // -1 | |
// calculate({ left: 1, right: 2, operator: '*' }) // 2 | |
// calculate({ left: 1, right: 2, operator: '/' }) // 0.5 | |
// calculate({ left: 1, right: 2, operator: '%' }) // null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment