Write a function useResource(log, work). First it adds the string 'open' to the array log, then it calls work() and returns its result. At the end 'close' always goes into log, even when work() throws. Do not swallow that error, let it go on as it is.
useResource([], () => 42)Returns 42
(() => { const log = []; useResource(log, () => 'done'); return log; })()Returns [ 'open', 'close' ]
Hidden tests run on Submit.