function div(x, y) {
return (x - x % y) / y;
}
function checked(number) {
const template = [1, 2, 5];
while (true) {
if (div(number, 100) > 0) {
number = div(number, 10);
} else {
return template.includes(div(number, 10));
}
}
}
let data = [10, 20, 30, 50, 235, 3000];
data.forEach(item => {
if (checked(item)) {
console.log(item);
}
});
function onEdit(e) {
var range = e.range;
var sheet = range.getSheet();
var names = ['Расход 09.19', 'Расход 10.19', 'Расход 11.19', 'Расход 12.19', 'Расход 01.20', 'Расход 02.20'];
if (names.indexOf(sheet.getName()) == -1) {
return false;
}
var col = range.getColumn();
var row = range.getRow();
var offset = 2;
if ((col > 4) && ((col - 5) % 3 == 0)) {
if (range.offset(0, offset).getValues() == '') {
sheet.getRange(row, col + offset).setValue(Utilities.formatDate(new Date(), 'GMT+03:00', 'HH:mm'));
}
}
}
function parseObject(object, name=undefined, result=[]) {
for (let key in object) {
if (object.hasOwnProperty(key)) {
if (key === 'show' && object['show']) {
result.push(name);
}
if (Object.prototype.toString.call(object[key]) === '[object Object]') {
parseObject(object[key], name ? `${name}.${key}` : `${key}`, result);
}
}
}
return result;
}
console.log(parseObject(obj)); // [ 'obj1', 'obj2', 'obj2.child.child2', 'obj3' ]