const str = 'abcde'
function reverseString(str) {
let tempString = ''
for(let j = str.length - 1; j >= 0; j--){
tempString += str[j]
}
return tempString
}
console.log('str:', str)
console.log('reverse:', reverseString(str))
const str = 'abcde'
function reverseString(str) {
return str.split('').reverse().join('')
}
console.log('str:', str)
console.log('reverse:', reverseString(str))
const duration = '30';
const startTime = moment().format('DD-MM-YYYY') // 26-10-2018
const endTime = moment().add(duration, 'days').format('DD-MM-YYYY') // 26-11-2018
const duration = {
years: '1',
months: '5',
days: '30'
};
const startTime = moment().format('DD-MM-YYYY') // 26-10-2018
const endTime = moment().add(duration).format('DD-MM-YYYY') // примерно 25-05-2020
.getElementsByClassName
- всегда возвращает коллекцию, даже если элемент один. var list = document.getElementsByClassName('list')[0];
var item = list.getElementsByClassName('item')[3];
let elem = document.querySelector('.element[data-attr=this-element]')
let [elem] = [...document.getElementsByClassName('element')]
.filter((item) => { return item.getAttribute('data-attr') === 'this-element' })
let [elem] = [...document.getElementsByClassName('element')]
.filter((item) => { return item.dataset.attr === 'this-element' })
document.body.addEventListener('click', function(e) {
console.log(e.target);
}
calc.addMethod("*", function(a, b) {
return a * b;
});
methods = {
"-": function(a, b) {
return a - b;
},
"+": function(a, b) {
return a + b;
},
"*": function(a, b) {
return a * b;
};