Converting time from 12-hour AM/PM format to 24-hour format without AM/PM – JavaScript

By using toLocaleTimeString() :

Explanation : 

1. time = "11:40:22 PM"
2. date = 2022-01-01T23:40:22.000Z (we can give any date as we are converting only time)
3. formattedTime = 23:40:22 ("en-GB" means 24-hour time without AM/PM)

Inserting a space at a specific index of a string – JavaScript

By using slice() method :

Explanation :

1. s = "12:40:22AM"
2. indexPosition = 10 - 2 = 8
3. result = 12:40:22 + " " + AM = 12:40:22 AM

Finding the Count of Largest numbers in the Array – JavaScript

By using filter method

By using reduce method