Home » javascript-programs

Day 4: Create a Rectangle Object (Hackerrank problem)

Objective In this challenge, we practice creating objects. Create a object with given length, width, perimeter, area. Task Complete the function in the editor. It has two parameters:  a and b. It must return an object modeling a rectangle that…

Read More »

Find the second largest element from array in javascript (Hackerrank problem)

Function Description Complete the getSecondLargest function in the editor below. getSecondLargest has the following parameters: int nums[n]: An array of integers number. (The largest number may be dublicate) Returns The second largest number

Read More »

Find the number of true in the array.

Create a function trueCount which returns the number of true values in the array. Examples Solution: const count_true = r => r.filter(Boolean).length or function trueCount(arr) { const trueCount = arr.reduce((total, item)=>total+Number(item), 0) return trueCount;}

Read More »