diff --git a/projects/JavaScript/mathOperations.js b/projects/JavaScript/mathOperations.js new file mode 100644 index 0000000..0d2b6b9 --- /dev/null +++ b/projects/JavaScript/mathOperations.js @@ -0,0 +1,16 @@ +// JavaScript ES6. You can import these functions to do simple Mathematical operations + +// Function to add two numbers +export const add = (a, b) => a + b; + +// Function to subtract two numbers +export const subtract = (a, b) => a - b; + +// Function to multiply two numbers +export const multiply = (a, b) => a * b; + +// Function to divide two numbers +export const divide = (a, b) => (b === 0 ? "Division by zero is not allowed" : a / b); + +// Function to calculate the percentage of a number +export const percentage = (value, percent) => (value * percent) / 100; \ No newline at end of file