What I am trying to do is make a function that takes user input, splits that input into an array of numbers, then replaces each number with a string depending on what the number is. It seems all this does now is return undefined, because it doesn't want to reassign the index to what It tell it to. I want to do this using a for loop or the forEach method if possible.
Here is my code so far:
function stringify(num){
var array = num;
for (i in array) {
if (array[i] == 2) {
array[i] = "x";
} else if (array[i] == 5) {
array[i] = "y";
} else {
array[i] = "meow"
}
return array;
}
}
Here is an example of what I want to eventually happen:
stringify(52527);
y x y x meow