document.querySelector(".main__order-items-wrapper").innerHTML(itemResult);
document.querySelector(".main__order-items-wrapper").innerHTML = itemResult;
let newArr =
{
"example": "name",
"word": 12,
"word": "noone",
"word": "2014",
"result": [
{
"name": "Ivan",
"age": "20"
},
{
"name": "OIga",
"age": "30"
}
]
};
let newArr2 = newArr.result.map(el => el.age * 2);
let newArr3 = newArr.result.map(el => {
return {name: el.name, age: el.age * 2};
});
console.log(newArr2);
console.log(newArr3);
const arr = [4, 63, 3, 87];
console.log(arr.sort((a, b) => a - b));
arr.push(2);
console.log(arr.sort((a, b) => a - b));
const arr1 = [1, 2, 3];
const arr2 = [1, 2, 3];
const arr3 = [3, 2, 1];
if (JSON.stringify(arr1) == JSON.stringify(arr2) || JSON.stringify(arr1) == JSON.stringify(arr3)) {
alert('correct');
} else {
alert('not right');
}
function factorial(n) {
let f = 1;
for (let i = 2; i <= n; i++) {
f *= i;
}
return f;
}
const getRandomRiver = (n, arr) => arr.sort(() => 0.5 - Math.random()).slice(0, n);
const getRandomRiver = (n, arr) => {
return arr
.map(x => ({ x, r: Math.random() }))
.sort((a, b) => a.r - b.r)
.map(a => a.x)
.slice(0, n);
}
return;
чтобы снова не добавлять классы.что я не слишком хорошо понимаю классы
class FirstClass {
constructor() {
this.importantVar = '1234asd'
}
someFunction() {
alert(this.importantVar);
}
}
class SecondClass extends FirstClass {
constructor(importantVar) {
super();
this.justAnotherVar = 'ooooo';
}
iWannaImportantVar() {
alert(this.importantVar);
}
}
function gasgasgas() {
const firstClass = new FirstClass();
const secondClass = new SecondClass();
firstClass.someFunction();
secondClass.iWannaImportantVar();
}
gasgasgas();