JSFiddle - React, Tailwind, and code Playground

by Vladymyr Shevchuk

JavaScript

function sumArguments() {
    return Array.from(arguments).reduce((accumulator, item) => {
        return (+accumulator) + (+item);
    });
}

function sortStrings(arrayForSort, orderType = 'ASC') {
    return arrayForSort.sort(function (a, b) {
    
        const isDescending = orderType.toUpperCase() === 'DESC';
        console.error('isDescending', isDescending);
        if (a > b) {
            return isDescending ? -1 : 1;
        }
        if (a < b) {
            return isDescending ? 1 : -1;
        }
        
        return 0;
    });
}

console.log(sumArguments(1,3,7));
console.log(sortStrings(['А', 'а']));