Hello programmers, today we are sharing proper solutions with all test cases passed on 10 Days of JavaScript by HackerRank.
As you all know JavaScript is the most popular and most challenging programming language to conquer but nowadays it’s not. There are some amazing platforms where that provide challenges in different languages and HackerRank is one of them.
In this challenge, we learn about arrays.
Before checking out the solution it’s highly recommended to do it by yourself first because these challenges will help you to think about how to deal with these real-world problems.
Let’s get started.
Here are a couple of related posts you may find helpful, too:
- Day 0: Hello, World! in Javascript| HackerRank Solutions
- Day 0: Data Types HackerRank Solution| Amazing 10 Days of JavaScript
- How to make money through coding? 9 Easy Ways To Make Money.
- 15+FREE Stuff For College Students Using Your College ID.
- how to get rich by coding? I make $100 every month from coding
Problem: Arrays in JavaScript

Overview: 10 Days of JavaScript| HackerRank Solution
/** * Return the second largest number in the array. * @param {Number[]} nums - An array of numbers. * @return {Number} The second largest number in the array. **/ function getSecondLargest(nums) { // Complete the function let max=0, second_max=0; for( let i=0; i<nums.length; i++){ if(nums[i] > max){ second_max=max; max= nums[i]; } else if(nums[i]<max && nums[i]>second_max){ second_max= nums[i]; } } return second_max; }
If you’d like to see some more articles, be sure to read more blogs so you can keep up to date with the latest design tutorials and tricks.
To contact me here’s my Instagram link: untied_blog
Pingback: Defination of demand, movement, the law of demand - Edudazz