function createIncrementoBeerMany(sum) {
return function (num) {
if (beerOne.checked) {
return (sum += num) * 30;
} else {
return (sum = 0);
}
};
}
const addWhitespace = (value, options = {}) => `${options.before ? ' ' : ''}${value}${options.after ? ' ' : ''}`;
addWhitespace('Hello', { before: true, after: true }); // --> " Hello "
const getPosition = (str) => {
switch (str) {
case 'today':
return 0;
case 'yesterday':
return 1;
case '18 February 2021':
return 2;
default:
return 3;
}
};
['18 February 2021', 'asdasda', 'yesterday', 'today'].sort((a, b) => getPosition(a) - getPosition(b));
так почему же мы можем обр. к свойствам как у массива и тд...?
const r = Array.prototype.map.call('qwerty', (ch) => ch.toUpperCase());
console.log(r);