function compoundMatch(w, t) {
const dict = {}
for (let i = 0; i < w.length; i++) {
if(dict[w[i]] === undefined) dict[w[i]] = i
}
for (const key in dict) {
if(t.startsWith(key)) {
const w2 = t.replace(key, '')
const found = dict[w2]
if(found) return [key, w2, [dict[key], found]]
}
if(t.endsWith(key)) {
const w2 = t.replace(key, '')
const found = dict[w2]
if(found) return [key, w2, [found, dict[key]]]
}
}
return null
}
compoundMatch=(S,Q,M)=>~(S.forEach((V,F)=>M[V]=F,M={}),V=S.findIndex(V=>V==Q.slice(0,V.length)&&null!=(B=M[Q.slice(V.length)])))?V<B?[S[V],S[B],[V,B]]:[S[B],S[V],[V,B]]:null
function compoundMatch(w, t) {
for (let i = 0; i < w.length; i++) {
const w1 = w[i]
if(t.startsWith(w1)) {
const w2 = t.replace(w1, '')
const found = w.indexOf(w2)
if(found !== -1) return [w1, w2, [i, found]]
}
if(t.endsWith(w1)) {
const w2 = t.replace(w1, '')
const found = w.indexOf(w2)
if(found !== -1) return [w1, w2, [found, i]]
}
}
return null
}
$("code").each(function(e) {
$(this).hover(function () {
console.log(this.classList);
})
});
на ЕС5 пробовать что-то написать это вообще мука какая-то, когда две строчки ЕС6 приходится раскладывать на 20 строчек вложенных циклов