const conditions= [
'and',
a === 3,
b === 7,
c !== 4,
['or', d < 15, c !== 5]
]
const countValue = (arr) => {
if(!Array.isArray(arr)) return arr
const cond = arr[0] === 'or'
? Array.prototype.some
: Array.prototype.every
return cond.bind(arr.slice(1), countValue)()
}
const conditions = [
'or',
['and', a === 7, b === 4],
['and', a < 8, b < 5]
]
console.log('result:' + countValue(conditions))
for (let i = 4; i <= num; i = i + 3) {
for (let i = 14; i <= num; i = i + 7) {
for (let i = 2; i <= num; i++) {
if (i % 2 !== 0) {
numArr.push(i);
}
}
const simpleNumbersSum = max => {
const arr = new Array(max + 1)
let sum = 1 + 2; //Или просто 2, если единицу не учитываем
for (let i = 3; i <= max; i+=2) {
if (!arr[i]) {
sum+=i;
for (let j = i * i; j <= max; j+=i*2) {
arr[j] = true;
}
}
}
return sum
}
console.log(simpleNumbersSum(977))
Object.keys(manage.UserBy).map(function(key) {
Object.keys(manage.UserBy).map(key => {
{Object.entries(manage.UserBy).map(([key, value]) =>
key == "id"
? <button onClick={this.handleClick} >Удалить</button>
: <div>{`${value} ${manage.price}%`}</div>
)}
new Set([...arr1, ...arr2]).size < arr1.length + arr2.length
arr1.find(v => arr2.includes(v))
function arrayHaveMatches(arr1, arr2) {
const arrays = [arr1, arr2]
const indexes = [0, 0]
let currArray = arr2[0] < arr1[0]
let val2 = arrays[!currArray][0]
while (indexes[currArray] < arrays[currArray].length) {
const val1 = arrays[currArray][indexes[currArray]]
if (val1 === val2) {
return true
} else if (val1 > val2) {
currArray = !currArray
val2 = val1
}
indexes[currArray] ++
}
return false
}
this.second = document.getElementById('inp_2').value;//второе число
this.button.onclick = evaluate