Sort by

recency

|

258 Discussions

|

  • + 0 comments

    I am getting the same error please use 'YES' all in captial letter. this dumb compiler is throwing error because I have written 'Yes'.

  • + 0 comments

    My simple solution:

        if (a > 0) {
            return "YES";
        } else if (a === 0) {
            throw new Error("Zero Error");
        } else {
            throw new Error("Negative Error");
        }
    
  • + 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;
        }
    }