"абвгдежзийклмнопрстуфхцчшщъыьэюя яюэьыъщшчцхфутсрпонмлкйизжедгвба"
, то должен вернуться 0.function result(line) {
let arr = line.split(' ');
let word1 = arr[0].split('');
let word2 = arr[1].split('');
if (word1.length != word2.length)
return 0;
var abc = "абвгдеёжзийклмнопрстуфхцчшщъыьэюя";
for (var i = 0; i < word1.length; i++)
if (!word1.every((e, j) => (e !== word1[i]) || (e == word1[i] && word2[j] == word2[i])))
return 0;
var i = 0;
while (word1.join("") != word2.join("")) {
if (word1[i] != word2[i]) {
var repS = word2[i];
if (word1.join("").indexOf(repS) != -1) {
var tempAbc = abc.split("").filter(w => word1.join("").indexOf(w) == -1);
if (tempAbc.length == 0)
return 0;
repS = tempAbc.pop();
}
word1 = word1.join("").replace(new RegExp(word1[i], "g"), repS).split("");
console.log(word1)
}
i = (i + 1) % word1.length;
}
return 1;
}
function randomEvenInt(min,max){
let v = Math.round(min+Math.random() * (max-min));
return v%2 != 0?v:randomEvenInt(min,max);
}
//Получить угол между двумя точками
function getAngle(dx, dy, dx1, dy1) {
return Math.atan2(dy - dy1, dx - dx1) + Math.PI;
}
///Получить растояние между двумя точками
function getDist(x, y, x1, y1) {
return Math.hypot(x - x1, y - y1);
}
var names = arr.map(e=>e.Data[0].name);
var counter = names.filter((v,i,arr)=> arr.indexOf(v) === i).map(el=>{
return {"name":el,"count" :names.filter(e=>el == e).length }
});
console.log(names)
console.log(counter)
["Sony", "Apple", "Sony"]
[{
count: 2,
name: "Sony"
}, {
count: 1,
name: "Apple"
}]
let box_h, item, co, staf;
co = document.querySelector(".boots");
staf = function(){
document.querySelectorAll(".push").forEach((e)=>{
e.addEventListener("click",(ev)=>{
console.log("good")
},false);
})
}
function g_global() {
//
box_h = "";
item = 5;
//
for(i = 0; i <= item; i++) {
box_h += '<div class="push"><button>нажми</button></div>'
}
//
co.innerHTML = box_h;
staf();
}
g_global();
$(document).on("keydown", e => {
if(e.key.search(/\d/) != -1)
$("span").append(e.key);
});
.box{
background:black;
}
.box.active{
background:red;
}
const elem = document.querySelectorAll('.box');
for (let i = 0; i < elem.length; i++)
elem[i].addEventListener('click', function (evt) {
var el = document.querySelector('.box.active');
if(el)
el.classList.remove("active");
evt.target.classList.add("active");
});
var arr = [
{date:"2020-04-28"},
{date:"2020-04-29"},
{date:"2020-04-30"},
{date:"2020-05-01"},
{date:"2020-05-02"},
{date:"2020-05-03"}
];
var find = Math.floor(+new Date()/86400000);
var finded = arr.find(e=>Math.floor(+new Date(e.date)/86400000) == find);//{date:"2020-05-01"}, если сегодня это число