Sort by

recency

|

257 Discussions

|

  • + 0 comments

    Here is My solution

    if (a === 0) throw new Error('Zero Error')
    else if (a < 0) throw new Error('Negative Error')
    else return 'YES'
    
  • + 1 comment

    Looks like there is something wrong with the compiler. I keep getting 6 lines of output when there are only 4 inputs from the test cases. Are you seeing the same thing?

  • + 1 comment

    Here's my solution:

    function isPositive(a) {
        try {
            if (a === 0) throw new Error('Zero Error');
            if (a < 0) throw new Error('Negative Error');
            return 'YES';
            }
        catch (error) {
            return error.message;
        }
    }
    
  • + 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
            }
        
    }