📌  相关文章
📜  第 17 天:javascript 代码示例中的更多异常hackerrank 解决方案

📅  最后修改于: 2022-03-11 15:02:21.046000             🧑  作者: Mango

代码示例1
// Day 17: More Exceptions hackerrank solution in javascript
//Write your code here
class Calculator {
    
    power(n,p){
        try{
           if((n>=0) && (p>=0)){
               return Math.pow(n,p);
           }else{
               error;
           }
            
        }
        catch(error){
            return "n and p should be non-negative";
        } 
    }
}