function User(name, age) {
this.name = name;
this.age = age;
}
const olga = new User('Olga', 20);
const res = items.filter(o => dictionary.some(v => v.code == 'seller' && v.id == o.role));
function sumStrings(s1, s2) {
if (s1.length < s2.length) [s1, s2] = [s2, s1];
s1 = [...s1].reduceRight((a, c, i) => {
c = +c + ~~s2[i - (s1.length - s2.length)] + a.r;
a.s = c % 10 + a.s;
a.r = c / 10 | 0;
return a;
}, {r: 0, s: ''});
return ((s1.r || '') + s1.s).replace(/^0+(?=\d)/, '');
}
const x = document.getElementById('wrap');
x.style.backgroundColor = 'black';
const pairs = { a: 'ა', b: 'ბ', g: 'გ'};
const str = 'There are many ways that reading helps you to learn English.';
[...str].map(letter => pairs[letter.toLowerCase()] || letter).join``;
const pairs = { a: 'ა', b: 'ბ', g: 'გ'};
const str = 'There are many ways that reading helps you to learn English.';
str.replace(RegExp(Object.keys(pairs).join('|'), 'gi'), letter => pairs[letter.toLowerCase()]);
const msg = str.match(/История общения[^]*(?= Автоматическое приветствие)/);
function twoSum(a, t) {
let o = {};
for (let i = 0; i < a.length; i++) {
if (o[a[i]] !== undefined) return [o[a[i]], i];
o[t - a[i]] = i;
}
}
const add_time = '2019-02-05 11:08:18';
add_time.replace(/-/g, '/').slice(2, -3); //19/02/05 11:08
myCrazyObject['some array'][2].number;
const traverse = (path, obj) => path.split('.').every(k => obj[k] && (obj = obj[k])) ? obj : null;
traverse('some array.2.number', myCrazyObject); //123
function foo() {
"use strict";
0321;
}
//Uncaught SyntaxError: Octal literals are not allowed in strict mode.