Skip to content

Instantly share code, notes, and snippets.

@clintonyeb
Created May 17, 2020 21:01
Show Gist options
  • Save clintonyeb/ddc21d8ac52d632bc26cc34bb4128646 to your computer and use it in GitHub Desktop.
Save clintonyeb/ddc21d8ac52d632bc26cc34bb4128646 to your computer and use it in GitHub Desktop.
/**
* @param {string} array Array
* @param {string} n Number of values that needs to be returned from Array
* @returns return new Array with the size n
*/
export function lastNMembers(array, n) {
if (array == null) {
return void 0;
}
if (n == null) {
return array[array.length - 1];
}
return array.slice(Math.max(array.length - n, 0));
}
/**
* @param {string} value The target for wrapper
* @returns Create html wrapper for moving average for displaying big number
*/
export function containerClassBig(value: string): string {
return `<span class="big">${value}</span>`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment