JavaScript
- 6 ответов
- 0 вопросов
6
Вклад в тег
const pattern = '...XX....XX.............X.......';
const parseStr = '...XX....XX.....X.......X...XX.X.';
const indices = pattern.split('').map((v, i) => v === 'X' ? i : '').join('');
const result = parseStr.split('').filter((v, i) => !~indices.search(i) ).join('');
function pow(x, n) {
const isNegative = n < 0;
let result = 1;
n = isNegative ? Math.abs(n) : n;
for (let i = 1; i <= n; i++) {
result *= x;
}
return isNegative ? (1 / result) : result;
}
function getStatistic(name, answer) {
const r = {
'+': true,
'ok': true,
'-': false,
'0': false
};
if (r[answer] === false) {
console.log(name + ` doesn't understand` )
} else {
console.log(name + ` understand`)
}
}
getStatistic(`Boris`, '-')
.header {
position: relative;
border-bottom: 4px solid transparent;
}
.header::after {
position: absolute;
z-index: 1;
left: 2.5%;
bottom: -4px;
width: 95%;
height: 4px;
content: '';
background-color: #f00;
}