|
| 1 | +const Calculator = require('./calculator'); |
| 2 | +const MathUtils = require('./mathUtils'); |
| 3 | + |
| 4 | +// Let's do some very convoluted math operations for no reason. |
| 5 | + |
| 6 | +const calc = new Calculator(); |
| 7 | + |
| 8 | +// We'll add 10 and 20, then check if the result is even or odd, and then square it, cube it, and find the factorial of the result. |
| 9 | + |
| 10 | +let sum = calc.add(10, 20); // Sum of 10 + 20 |
| 11 | + |
| 12 | +let isEven = MathUtils.isEven(sum); // Is the sum even? |
| 13 | +let isOdd = MathUtils.isOdd(sum); // Is the sum odd? |
| 14 | + |
| 15 | +console.log(`Sum: ${sum}`); |
| 16 | +console.log(`Is the sum even? ${isEven}`); |
| 17 | +console.log(`Is the sum odd? ${isOdd}`); |
| 18 | + |
| 19 | +let squared = MathUtils.square(sum); // Square of the sum |
| 20 | +let cubed = MathUtils.cube(sum); // Cube of the sum |
| 21 | + |
| 22 | +console.log(`Squared sum: ${squared}`); |
| 23 | +console.log(`Cubed sum: ${cubed}`); |
| 24 | + |
| 25 | +let factorial = MathUtils.factorial(sum); // Factorial of the sum |
| 26 | + |
| 27 | +console.log(`Factorial of sum: ${factorial}`); |
| 28 | + |
| 29 | +// Now let's subtract the sum by 5, check if it's even, square it again, then divide by 3 |
| 30 | +let result = calc.subtract(sum, 5); |
| 31 | +let resultSquared = MathUtils.square(result); |
| 32 | +let resultDivided = calc.divide(resultSquared, 3); |
| 33 | + |
| 34 | +console.log(`Subtract 5 from sum: ${result}`); |
| 35 | +console.log(`Squared result: ${resultSquared}`); |
| 36 | +console.log(`Result divided by 3: ${resultDivided}`); |
0 commit comments