if the function calculateAvgGainLoss
response includes avgGain, avgLoss
we can get these values like this.
const { avgGain, avgLoss } = calculateAvgGainLoss(prices);
I want to set these values to the variable that defined outside of the function. How can I do that ? Example below.
describe("test", () => {
let avgGain: number, avgLoss: number;
it("Calculate average gain & loss", () => {
const prices = [...];
/*...This isn't working, has to be changed...*/ { avgGain, avgLoss } = calculateAvgGainLoss(prices);
expect(avgGain).toBe(0.24);
expect(avgLoss).toBe(0.1);
});
});