Моё решение:
// Алфавит
var symbols = [‘А’, ‘Б’, ‘В’, ‘Г’, ‘Д’, ‘Е’, ‘Ё’, ‘Ж’, ‘З’, ‘И’, ‘Й’, ‘К’, ‘Л’, ‘М’, ‘Н’, ‘О’, ‘П’, ‘Р’, ‘С’, ‘Т’, ‘У’, ‘Ф’, ‘Х’, ‘Ц’, ‘Ч’, ‘Ш’, ‘Щ’, ‘Ъ’, ‘Ы’, ‘Ь’, ‘Э’, ‘Ю’, ‘Я’, ‘а’, ‘б’, ‘в’, ‘г’, ‘д’, ‘е’, ‘ё’, ‘ж’, ‘з’, ‘и’, ‘й’, ‘к’, ‘л’, ‘м’, ‘н’, ‘о’, ‘п’, ‘р’, ‘с’, ‘т’, ‘у’, ‘ф’, ‘х’, ‘ц’, ‘ч’, ‘ш’, ‘щ’, ‘ъ’, ‘ы’, ‘ь’, ‘э’, ‘ю’, ‘я’, ’ ', ‘.’, ‘,’, ‘—’, ‘!’];
// Смещение
var shift = 10;
console.log(symbols.length)
// Закодированное сообщение
var encodedMessage = [8, 28, 36, 52, 56, 40, 23, 31, 56, 39, 38, 28, 48, 52, 58, 56, 38, 27, 32, 37, 56, 40, 23, 31, 56, 39, 38, 41, 39, 32, 57];
// Раскодированное сообщение
var decodedMessage = ‘’;
var decod = [];
for(i = 0; i < encodedMessage.length; i++){
var indexMessange = encodedMessage[i] + shift;
if(indexMessange <= symbols.length){
decod.push(symbols[indexMessange])
decodedMessage = decod.join(’’);
} else {
decod.push(symbols[indexMessange - symbols.length])
decodedMessage = decod.join(’’);
}
}
console.log(decodedMessage);