I want to learn how to clean my code up and I feel like the reverse string function can be turned into a variable. Is this possible?
function reverseString(str) {
return str.split('').reduce((revString, char) => char + revString, '');
}
const reverse = reverseString('Cornell');
console.log(reverse);
const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9];
const sum = numbers.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
console.log(sum);