You are viewing a single comment's thread. Return to all comments →
Try to strictly follow the rules. Use try, catch block, and error propogation handling. Here is my JS version, improve it.
function Calculator(){ this.power = function(n, p){ try{ if(n < 0 || p < 0) throw("n and p should be non-negative"); return Math.pow(n,p); } catch(e){ throw(e); } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Day 17: More Exceptions
You are viewing a single comment's thread. Return to all comments →
Try to strictly follow the rules. Use try, catch block, and error propogation handling. Here is my JS version, improve it.