There are two arrays, for example: ['i','b'] and ['и','б']
It is necessary to replace characters from the first array with characters from the second array. More precisely, to i = и , etc.

Example:

 var firstArray = ['d','e','v','e','l','o','p','e','r']; var secondArray = ['д','е','в','е','л','о','п','е','р']; 

thirdArray needs to thirdArray values ​​from secondArray . As a result, the thirdArray should be equal to ['д','е','в','е','л','о','п','е','р']

I tried to somehow replace , but failed. Therefore, I am writing here

  • one
    the essence of the question is not clear, well, then take the second array immediately, or just make firstArray = secondArray , I think you did not correctly formulate the question. - Raz Galstyan
  • @RazmikGalstyan most likely he has thirdArray a la ['h','e','l','l','o','w','o','r','l','d'] , and the first and second arrays are a ru-en match. But this is only a guess) - Alexey Shimansky
  • @ AlekseySh we will wait for the fortune-teller)))) - Raz Galstyan
  • I need to change characters from 1 array to characters from 2 array. For example, if in the first array there is a symbol "s", then you need to replace it with a symbol from the second array ":)" - Aliev A.

1 answer 1

 const ru = ['а', 'б', 'в', 'г', 'д']; const en = ['a', 'b', 'v', 'g', 'd']; const transliterateArray = arr => arr.map(letter => ru.indexOf(letter) >= 0 ? en[ru.indexOf(letter)] : letter); const transliterateString = str => transliterateArray(str.split('')).join(''); const array = transliterateArray(['д', 'б', 'г']); const string = transliterateString('ваб') console.log(array) console.log(string);