21 Day Coding Challenge

Message.replace is not a function challenge 20/21

#1

Yesterday, I cleared challenge 20, but today, it is giving error that - message.replace is not a function

function decodeMessage(message){
message = message
.replace(/1/g, ‘i’)
.replace(/4/g, ‘a’)
.replace(/3/g, ‘e’)
.replace(/0/g, ‘o’)
.replace(/2/g, ‘u’);

return message;
}

function returnToEarth(){
var broadx = broadcast(‘x’);
var broady = broadcast(‘y’);
var broadz = broadcast(‘z’);

var parsedx = parseInt(broadx, 16);
var parsedy = parseInt(broady, 16);
var parsedz = parseInt(broadz, 16);

navigation.x = decodeMessage(parsedx);
navigation.y = decodeMessage(parsedy);
navigation.z = decodeMessage(parsedz);
}

returnToEarth();

1 Like
#2

It might not be related, but you don’t seem to have a value for 5…

Also, you seem to be inverting two steps…

Broacast -> decodeMessage -> parseInt…

It doesn’t exactly justify your error message, though, but that could definitely get in your way…

2 Likes
#3

Got it, you are the champ! @Seb :slight_smile::star_struck:

1 Like