Poznakomlus,
Спасибо за помощь, хоть проблема и не пропала, теперь код короче!
var txt = "АБВ";
function toWeight(inp,a){ // функция принемает на вход текст (inp) и просто переменную равную 0 (a)
// я знаю что переменную можно объявить и здесь, но тогда вообще ничего не работает...
this.inp = inp.toUpperCase();
this.len = this.inp.length;
this.a = a;
let abc = [[" ","А","Б","В","Г","Д","Е","Ж","З","И","К","Л","М","Н","О","П","Р","С","Т","У","Ф","Х","Ц","Ч","Ш","Щ","Ъ","Ы","Ь","Э","Ю","Я"],
[ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]];
for(var i = 0; i < len; i ++){
for(var j = 0; j < 31; j++){
if (this.inp[i] == abc[0][j]){
this.a += abc[1][j];
}
}
}
var ret = (this.a * 999999999) % 25022020;
return ret;
}
var b = toWeight(txt,0);
var out = b.toString(16);
document.write(out);