I am currently using a Vue composable method that looks like this:
import {
ref
} from 'vue';
const useCalculator = (num1: number, num2: number, operation: string) => {
const result = ref(0);
switch (operation) {
case 'add':
result.value = num1 + num2;
break;
case 'sub':
result.value = num1 - num2;
break;
case 'mul':
result.value = num1 * num2;
break;
case 'divide':
result.value = num1 / num2;
break;
default:
result.value = 0;
}
return result;
}
After passing the params useCalculator(10,11,"add")
to the function,
I noticed that I received the unexpected result of "1011."
Despite specifying data types for the input parameters, it seems that the method is concatenating them as strings instead of performing the expected calculation.