'How would you rotate numbers in string using a rotational cypher?

Hello I'm trying to solve the classic rotational cypher problem but im also trying to solve for when numbers are included in the string. So far this is the method I have been going about it using javascript:

function rotationalCipher(input, rotationFactor) {

const originalAlpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

return input.replace(/[a-z]/gi, letter => originalAlpha[originalAlpha.indexOf(letter)+rotationFactor]);
  

}

It works but it doesn't address the numbers within the string. Id be appreciative of any help.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source