follow along with tests

This commit is contained in:
Pablo Martin 2025-06-04 17:58:33 +02:00
parent f58ef53347
commit 9bd54f4719
4 changed files with 57 additions and 1 deletions

View file

@ -0,0 +1,16 @@
const reverse = (string) => {
return string.split("").reverse().join("");
};
const average = (array) => {
const reducer = (sum, item) => {
return sum + item;
};
return array.length === 0 ? 0 : array.reduce(reducer, 0) / array.length;
};
module.exports = {
reverse,
average,
};