function check(arr) {
let seqGrow = 0;
for (let i = 1; i < arr.length; i++) {
const pairGrow = Math.sign(arr[i] - arr[i - 1]);
if (pairGrow === 0) {
continue;
}
seqGrow = seqGrow || pairGrow;
if (pairGrow !== seqGrow) {
return false;
}
}
return true;
}
console.log(check([0, 1, 5, 9, 15]));
console.log(check([0, 1, 1, 5, 9, 9, 15]));
console.log(check([15, 8, 4, 2, 1]));
console.log(check([0, 1, 5, 15, 4]));
const pathHandler = {
get(target, prop) {
const val = target[prop];
if (typeof val === 'object' && val.hasOwnProperty('src')) {
val.toString = function() {
return this.src;
};
return new Proxy(val, pathHandler);
} else {
return target[prop];
}
}
}
const path = new Proxy({
styles: {
src: './path-to-styles-src',
dist: './path-to-styles-dist',
scss: {
src: './scss-src',
dist: './scss-dist',
}
},
images: {
src: './path-to-images-src',
dist: './path-to-images-dist'
},
}, pathHandler);
console.log('' + path.styles); // './path-to-styles-src'
console.log('' + path.styles.dist); // './path-to-styles-dist'
console.log('' + path.styles.scss); // './scss-src'
console.log('' + path.styles.scss.dist); // './scss-dist'
Game.prototype.knight = function(game, gameSize,position){
this.game = game;
this.position = {x : 150, y : 150};
this.size = {x : 200, y : 230};
this.current = 0;
this.knight = []; // <----- упс! следующий вызов this.knight() окажется неудачным.
}
transformable element
- all elements whose layout is governed by the CSS box model except for non-replaced inline boxes, table-column boxes, and table-column-group boxes
https://drafts.csswg.org/css-transforms-1/#terminology
<a>
по дефолту инлайновые элементы div.insertBefore(loginMessage, password);
попробуй password.parentElement.insertBefore(loginMessage, password);
function readNumber() {
let answer = prompt('Введите число?', 0);
if (isFinite(answer) == true && answer != '') {
alert('Это число: ' + answer);
} else {
setTimeout(readNumber, 0);
}
}