Day 3: Try Catch Finally - HACKERRANK - 10 Days of JavaScript

Опубликовано: 24 Апрель 2026
на канале: Joshua
1,334
36

Support my channel by donating to my CashApp. Even $5 helps!
https://cash.app/$JoshuaCadavez

*******************************************************************************************
Or give advice or alternative solutions in the comments below!
Problem: https://www.hackerrank.com/challenges...

Complete the reverseString function; it has one parameter, 's'. You must perform the following actions:

1. Try to reverse string 's' using the split, reverse, and join methods.
2. If an exception is thrown, catch it and print the contents of the exception's 'message' on a new line.
3. Print 's' on a new line. If no exception was thrown, then this should be the reversed string; if an exception was thrown, this should be the original string.

More CodeSignal:    • CodeSignal  

More LeetCode:    • Leetcode  

More HackerRank:    • HackerRank  

*******************************************************************************************

Follow me on:
Twitter -   / joshuacadavez  
LinkedIn -   / joshuacadavez  
GitHub - https://github.com/JoshuaTheEngineer