Sort by

recency

|

254 Discussions

|

  • + 0 comments
    function isPositive(a) {
      if (a > 0) {
        return "YES";
      } else if (a === 0) {
        throw new Error("Zero Error");
      } else {
        throw new Error("Negative Error");
      }
    }
    
  • + 0 comments
    function isPositive(a) {
        
            try{
                if(a>0){return "YES"}
                if(a==0){throw new Error("Zero Error")}
                if(a<0){throw new Error("Negative Error")}
            }catch (e){
                return e.message
            }
        
    }
    
  • + 0 comments

    function isPositive(a) { const verify = a;

    if (verify >= 1) { 
        return 'YES'
    } else if (verify === 0) {
        throw new Error('Zero Error')
    } else {
        throw new Error('Negative Error')
    }
    

    }

  • + 0 comments

    function isPositive(a) {

        if(a>0) {
            return "YES"
    
        } else if(a==0) {
            throw new Error("Zero Error")
    
        } else if(a<0) {
            throw new Error("Negative Error")
    
        }
    

    }

  • + 0 comments
      if(a <= 0){
           throw new Error(a == 0 ? "Zero Error" : "Negative Error");
       } 
        return "YES";