1 min to read
10 Days of JavaScript Day 3: Arrays, Try Catch and Finally & Throw
Day 3 of 10 Days of JavaScript challenge on Hackerrank is Arrays, Try Catch and Finally & Throw. In this series, I will be sharing my solutions to the challenges.
Day 3: Arrays
- Get the second largest number in an array of numbers.
Day 3: Try, Catch, and Finally
- Reverse the string s using the split, reverse, and join methods and ensure it does not throw an error if passed an empty string
Day 3: Throw
Complete the isPositive
function below. 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.