- Edited
This is the code I tried and it runs well in the editor but whenever I try to submit it, it shows "Exceeded execution timeout of 40 seconds". Please help.
export const pow = (x, y) => {
let power = x;
if(y === 0) {
return 1;
}
if(y === 1) {
return x;
}
for(let i = 2; i <= y; i++) {
power *= x;
}
return power;
}