I’ve found a great code which is built for finding peaks in arrays, which print the result in the console (Finding peaks and troughs in time series data in a 1D array - Javascri