This commit is contained in:
Philippe Torrel
2026-10-22 11:46:40 +02:00
parent 5d11cf5541
commit 5b6dc89bb5
52 changed files with 8144 additions and 11 deletions
@@ -1,4 +1,13 @@
import { add, subtract } from './math';
import { add, subtract, divide, multiply } from './math';
import Helper from './math';
console.log(add(1, 2)); // => 3;
console.log(subtract(3, 2)); //=> 1
console.log(divide(6, 3)); //=> 2
console.log(multiply(3, 2)); //=> 6
console.log(Helper.add(1, 2)); // => 3;
console.log(Helper.subtract(3, 2)); //=> 1
console.log(Helper.divide(6, 3)); //=> 2
console.log(Helper.multiply(3, 2)); //=> 6
@@ -7,7 +7,14 @@ export const subtract = (a, b) => a - b;
// Übung 2: Mathfunktionen als Modul
// Programmiere zwei weitere Module, die jeweils eine Funktion multiply und divide enthalten. Importiere die Funktionen in der main.js-Datei und führe sie aus.
export const multiply = (a, b) => a * b;
export const divide = (a, b) => a / b;
// Übung 3: Exportieren Funktionen als Objekt
// Anstatt die Funktionen add, subtract, multiply und divide benannt zu exportieren, exportiere sie als Standard-Export in einem Objekt. Importiere das Objekt in der main.js-Datei und führe die Funktionen aus.
export default { add, subtract, multiply, divide };
// commonjs
// module.exports = { add, subtract, multiply, divide };