I have a string called
"Pizza2Day!"
that I want to replace using a array set. In this array set I have the original alphabets as reference
var originalValues = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
and then I have the encryption key set
var encryptedValues = ['m', 'h', 't', 'f', 'g', 'k', 'b', 'p', 'j', 'w', 'e', 'r', 'q', 's', 'l', 'n', 'i', 'u', 'o', 'x', 'z', 'y', 'v', 'd', 'c', 'a'];
what I want to do is find any occurrences in the original string "Pizza2Day" of normal alphabets (a,b,c,d) and replace them with their substitutes in the encryption set (m,n,h,f). So the result would be "Njaam2Fmc!"
How would I go about doing this? Will a loop come in handy in this case?