Skip to content

Latest commit

 

History

History

throw-challenge

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Creating throw-challenge project

Practice using trow statement:

Complete the isPositive function. It has one integer parameter, a.
If the value of a is positive, it must return the string YES.
Otherwise, it must throw an Error according to the following rules:

  • if a is 0, throw an Error with message = Zero Error
  • if a is negative, throw an Error with message = Negative Error

Constraints:

  • 1 <= n <= 5
  • -100 = a <= 100

Sample input:

3
-6
0
8


Sample output:

YES
Negative Error
Zero Error
YES