21 Day Coding Challenge

Challenge 20 - Stuck

#1

I can’t seem to figure this one out. Here is my code, any suggestions are appreciated:

function decodeMessage(message){
  radio.message = radio.message.split(" ");
  for(var i = 0; i < radio.message.length; i++){
  radio.message[i] = radio.message[i].replace(/0/g, "o")
  radio.message[i] = radio.message[i].replace(/1/g, "i")
  radio.message[i] = radio.message[i].replace(/2/g, "u")
  radio.message[i] = radio.message[i].replace(/3/g, "e")
  radio.message[i] = radio.message[i].replace(/4/g, "a")
  radio.message[i] = radio.message[i].replace(/5/g, "y")
  }
  return radio.message.join(" ");
  }
#2

radio.message?

The message we’re working with isn’t related to that…

:upside_down_face:

#3

Also adding to Seb’s comment
You don’t really need the loop if you are doing /_/g, '_'

message.replace(/0/g, "o").replace(/1/g, "i") // etc etc etc

Cheers

1 Like
#5

If you want to use split - then just split the message on the digit, then join back with the character.
e.g. msg = msg.split(‘4’).join(‘a’);
No need to loop here either.

#6

aha!

got it thanks, thanks