diff --git a/staff/joseramon-rodriguez/playground/calculator/index.ts b/staff/joseramon-rodriguez/playground/calculator/index.ts new file mode 100644 index 0000000..617e2fc --- /dev/null +++ b/staff/joseramon-rodriguez/playground/calculator/index.ts @@ -0,0 +1,24 @@ +function calculate(op: '+' | '-' | '*' | '/', x: number, y: number) { + switch (op) { + case '+': + return x + y + case '-': + return x - y + case '*': + return x * y + case '/': + return x / y + } +} + +console.log(calculate('+', 1, 1)) +//2 + +console.log(calculate('-', 1, 1)) +//0 + +console.log(calculate('*', 1, 1)) +//1 + +console.log(calculate('/', 2, 1)) +//2 \ No newline at end of file