Mixed messages returns undefined. (super-encoder)

Hey everyone! I could really use some help right now. I have been trying for hours on fixing this issue but have got nowhere, In my Mixed messages the super-encoder returns “undefined” when it takes a message to encode.
I would really appreciate some help. Thanks!!

// Import the encryptors functions here.
const encryptors = require('./encryptors.js')
// Encryption Functions
/////////////////////////////////////////////
const caesarCipher = encryptors.caesarCipher;
const symbolCipher = encryptors.symbolCypher;
const reverseCipher = encryptors.reverseCipher;

const encodeMessage = (str) => {
  // Use the encryptor functions here.
  return reverseCipher(str);
}

const decodeMessage = (str) => {
  // Use the encryptor functions here.
  return reverseCipher(str);
}

// User input / output.

const handleInput = (userInput) => {
  const str = userInput.toString().trim();
  let output;
  if (process.argv[2] === 'encode') {
    output = encodeMessage(str);
  } 
  if (process.argv[2] === 'decode') {
    output = decodeMessage(str);
  } 
  
  process.stdout.write(output + '\n');
  process.exit();
}

// Run the program.
process.stdout.write('Enter the message you would like to encrypt...\n> ');
process.stdin.on('data', handleInput);

Hi @fxfey
welcome to the forums!
how did you export the modules from encryptors.js?

module.exports.caesarCipher = caesarCipher;
module.exports.symbolCipher = symbolCipher;
module.exports.reverseCipher = reverseCipher;

Like this :slight_smile:

Ok, that is fine. And have you shifted all the functions you export to the encryptors file? Are you working in the CC environment?
How do you run the program when you get undefined?

Yes, I shifted all the files over. I do not believe I’m working in the CC environment.
I first put in node super-encoder.js encode and then from there when I put in the message I get undefined.

I think I was a little unclear: Do you do the exercise locally in your code editor or online in the Codecademy editor?
When do you get undefined? When you run the program in your terminal with

node super-encoder.js encode

or what do you do when you get undefined?

I am doing the exercise in the Codecademy editor,
okay this is really weird it’s now working? i haven’t changed anything, and now ive added multiple Ciphers

const encodeMessage = (str) => {
  // Use the encryptor functions here.
  return reverseCipher(symbolCipher(caesarCipher(str, 6)));
}

It has returned
return reverseCipher(symbolCipher(caesarCipher(str, 6)));
^

TypeError: symbolCipher is not a function

I realise I now made a spelling error somewhere in my code, ■■■■

But that spelling error wasn’t in the code you posted, right? That seemed fine…

Yeah, very weird series of events… its working fine now :face_with_raised_eyebrow: