Day 3: Throw in JavaScript | 10 Days Of JavaScript Solutions | HackerRank Programming Solutions [💯Correct]

Hello Programmers/Coders, Today we are going to share solutions of Programming problems of HackerRank, 10 Days Of JavaScript. At Each Problem with Successful submission with all Test Cases Passed, you will get an score or marks. And after solving maximum problems, you will be getting stars. This will highlight your profile to the recruiters.

In this post, you will find the solution for Day 3: Throw in JavaScript-HackerRank Problem. We are providing the correct and tested solutions of coding problems present on HackerRank. If you are not able to solve any problem, then you can take help from our Blog/website.

Use “Ctrl+F” To Find Any Questions Answer. & For Mobile User, You Just Need To Click On Three dots In Your Browser & You Will Get A “Find” Option There. Use These Option to Get Any Random Questions Answer.

Introduction To JavaScript

JavaScript is a lightweight, cross-platform, and interpreted scripting language. It is well-known for the development of web pages, many non-browser environments also use it. JavaScript can be used for Client-side developments as well as Server-side developments. JavaScript contains a standard library of objects, like Array, Date, and Math, and a core set of language elements like operators, control structures, and statements.

Advantages of JavaScript

The merits of using JavaScript are −

  • Less server interaction − You can validate user input before sending the page off to the server. This saves server traffic, which means less load on your server.
  • Immediate feedback to the visitors − They don’t have to wait for a page reload to see if they have forgotten to enter something.
  • Increased interactivity − You can create interfaces that react when the user hovers over them with a mouse or activates them via the keyboard.
  • Richer interfaces − You can use JavaScript to include such items as drag-and-drop components and sliders to give a Rich Interface to your site visitors.

Link for the ProblemDay 3: Throw – Hacker Rank Solution

Day 3: Throw – Hacker Rank Solution



In this challenge, we practice using throw and catch statements to work with custom error messages.


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

  • If  is , throw an Error with  Zero Error.
  • If  is negative, throw an Error with  Negative Error.

Input Format

Locked stub code in the editor reads the following input from stdin and passes each value of  to the function as an argument:
The first line is an integer, , denoting the number of times the function will be called with some .
Each line  of the  subsequent lines contains an integer denoting some .


Output Format

If the value of  is positive, the function must return the string YES. Otherwise, it must throw an Error according to the following rules:

  • If  is , throw an Error with  Zero Error.
  • If  is negative, throw an Error with  Negative Error.

Sample Input 0


Sample Output 0


Explanation 0

Each of the given values is positive, so we return YES each time. The value returned during each function call is printed on a new line by locked stub code in the editor.

Sample Input 1


Sample Output 1

Zero Error

Explanation 1

Locked stub code in the editor makes the following three calls to the isPositive function:

  1. isPositive(2): This returns YES because  is positive.
  2. isPositive(0): Because , we throw an Error with  Zero Error. This is caught by the locked stub code and the value of its  is printed.
  3. isPositive(6): This returns YES because  is positive.

Sample Input 2


Sample Output 2

Negative Error

Explanation 2

Locked stub code in the editor makes the following two calls to the isPositive function:

  1. isPositive(-1): Because , we throw an Error with  Negative Error. This is caught by the locked stub code and the value of its  is printed.
  2. isPositive(20): This returns YES because  is positive.
Day 3: Throw – Hacker Rank Solution
function isPositive(a) {
  if (a === 0) {
    throw Error("Zero Error");
  if (a < 0) {
    throw Error("Negative Error");
  return "YES";

173 thoughts on “Day 3: Throw in JavaScript | 10 Days Of JavaScript Solutions | HackerRank Programming Solutions [💯Correct]”

  1. how can i get cheap mobic without prescription [url=]where to buy generic mobic without insurance[/url] where can i get cheap mobic without dr prescription

  2. Celtic will begin the defence of their Scottish Premiership title at home to Aberdeen on Sunday July 31. Speaking after the announcement of the game, Rovers manager John Russell said he is looking forward to welcoming Celtic B to The Showgrounds. Tuesday, Locomotive Tbilisi 4-2 Kafue Celtic Watch all of Celtic’s upcoming games live by checking our Complete Celtic TV Online Broadcast Listings below. The 2012 financial collapse and subsequent liquidation, and reformation, of Rangers has added a new dimension to the rivalry. After being reformed as a new company and starting at the bottom of the Scottish League system in 2013, certain segments of the Celtic fanbase assert that today’s Rangers is not the true “Old Firm” club of years past. Despite the legal technicalities of the holding company of the Rangers identity, however, the fixture is no less important. Rangers were forced to start in the fourth tier from 2012 13, but in just four seasons quickly earned their way back into the Premiership. They won their first league title since being back up in 2020 21.
    Exclusive offer from Vbet San Diego Legion won over the Seattle Seawolves Sunday night in the MLR Championship Western Conference Finals. The Match will be available for streaming on The Rugby Network after 3pm Monday, July 3rd. Reigning champions Australia, hosts England and world number one New Zealand will cross paths with dark horses Tonga and Samoa, plus newcomers Greece and Jamaica, over a month of pulsating action. Friday’s clash against South Sydney at Go Media Stadium Mt Smart is sold out. Betfred Championship Round 25Saturday 9th SeptemberToulouse Olympique HOMEThe Shay Stadium 6pm Final result: Queensland Maroons 18 def. NSW Blues 14Half-time score: Queensland Maroons 0 trailed NSW Blues 10First try-scorer: Damien Cook (15′)Man of the match: Daly Cherry-Evans (QLD) Saturday 5 August, 3pm

  3. canadian mail order pharmacy [url=]canadian pharmacy online reviews[/url] canadian pharmacy tampa

  4. Thanks for ones marvelous posting! I seriously enjoyed reading it, you will be a great author.
    I will make sure to bookmark your blog and will eventually come back at some point.
    I want to encourage continue your great job, have a nice holiday weekend!

  5. To announce present news, dog these tips:

    Look representing credible sources: It’s material to safeguard that the expos‚ outset you are reading is respected and unbiased. Some examples of reputable sources subsume BBC, Reuters, and The Fashionable York Times. Read multiple sources to get a well-rounded aspect of a precisely news event. This can help you listen to a more complete display and keep bias. Be in the know of the position the article is coming from, as flush with respectable telecast sources can be dressed bias. Fact-check the dirt with another origin if a communication article seems too unequalled or unbelievable. Till the end of time be unshakeable you are reading a known article, as scandal can change-over quickly.

    By following these tips, you can evolve into a more informed news reader and better apprehend the beget here you.

  6. Absolutely! Conclusion information portals in the UK can be unendurable, but there are scads resources ready to boost you mark the unmatched the same for you. As I mentioned before, conducting an online search an eye to “UK scuttlebutt websites” or “British intelligence portals” is a great starting point. Not no more than will this hand out you a comprehensive slate of hearsay websites, but it determination also lend you with a punter understanding of the current communication scene in the UK.
    Aeons ago you obtain a list of imminent news portals, it’s powerful to gauge each anyone to determine which upper-class suits your preferences. As an example, BBC Dispatch is known benefit of its ambition reporting of news stories, while The Keeper is known for its in-depth criticism of governmental and group issues. The Independent is known representing its investigative journalism, while The Times is known in the interest of its business and funds coverage. By way of concession these differences, you can pick out the news portal that caters to your interests and provides you with the rumour you have a yen for to read.
    Additionally, it’s usefulness looking at close by news portals representing proper to regions within the UK. These portals lay down coverage of events and dirt stories that are relevant to the area, which can be exceptionally cooperative if you’re looking to charge of up with events in your close by community. For event, provincial good copy portals in London include the Evening Canon and the Londonist, while Manchester Evening Hearsay and Liverpool Reflection are stylish in the North West.
    Comprehensive, there are diverse bulletin portals accessible in the UK, and it’s high-ranking to do your research to remark the one that suits your needs. By evaluating the different news programme portals based on their coverage, style, and essay perspective, you can choose the song that provides you with the most related and engrossing low-down stories. Good fortunes with your search, and I hope this information helps you find the just right news broadcast portal since you!

  7. Pierwsze co musisz zrobić, to wybrać miejsce do gry, założyć bezpłatne konto gracza i ściągnąć grę. W ten sposób uzyskasz możliwość gry z tysiącami innych graczy, którzy każdego dnia i o każdej porze uczestniczą w setkach turniejów i gier. Biorąc udział w darmowych turniejach, możesz wygrywać i budować bankroll, nie ryzykując ani złotówki – serwisy pokerowe prześcigają się w różnego rodzaju promocjach zachęcając użytkowników pulami darmowych żetonów czy turniejami bez wpisowego – freeroll. Niszę, którą stworzyło obecne ustawodawstwo, próbują zapełnić polscy legalni bukmacherzy, którzy stworzyli zakłady na symulowane gry w karty. Jako pierwszy na polski rynek wprowadził je pod nazwą Betgames bukmacher STS. Polega to na obstawianiu wyniku rozgrywki pokera online, przeprowadzanej przez prawdziwego krupiera. Oto bukmacherzy, którzy oferują zakłady na pokera online:
    İçerik Türkiye’de En Iyi Mobil Blackjack Için Türkiye’de Online Casino Sıralaması Sweet Bonanza Slot Oyna Paralı Poker Siteleri Pragmatic Play Kumarhane En Iyi Mobil Blackjack Ekşi Kolaybetten %100 Casino Hoşgeldin Bonusu Tüm Yatırım Metodlarına Türkiye’de Casino Istemci Yazılımını Indirmek Için Ne Gibi Adımlar Atmam Gerekiyor Kayıt Bonusu Veren Siteler Yeni Slot Için 10 Euro Ücretsiz … Wskazówki, jak zwiększyć szanse na wygraną w 1xbet, są zbierane przez ekspertów z Finance de Demain aby pomóc nowym graczom i każdemu, kto chce zwiększyć swoje szanse na wygraną. Znajdź 10 wskazówek, jak wygrać gry 1xbet wymienione poniżej. Początkowo Negreanu odniósł się do klęski Jonnie Vibes mark-up, która skłoniła jego ostatnią walkę z Deebem. Mam nadzieję, że dobrze rozumiem, że zostałeś poproszony o uiszczenie opłaty manipulacyjnej za żądaną wypłatę. W Amazing Casino możesz dodać do swojego konta do 3 kart płatniczych. Wszystkie z nich są przedstawione w tabeli płatności, gdzie określony jest dla nich współczynnik.


Leave a Comment

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker🙏.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock