Issues with message mixer super encoder

Hi! So I am tackling hte project and I have managed to make it work as long as I don’t use the symbolCipher function with the super-encoder because node tells me it is not a function. So this is my super encoder code:

// Import the encryptors functions here.
const { caesarCipher, symbolCipher, reverseCipher } = require('./encryptors.js');


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

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

What is after that is the default text that I have not touched. I can use bith reverse and caesar without problems as you can see but error is thrown every time I use symbol.

just like the task required I copied it without touching it in encryptors.js but just in case here are the functions that I am supposed to be exporting.

// Declare and export the functions here.const 
const caesarCipher = (str, amount = 0) => {
  if (amount < 0) {
    return caesarCipher(str, amount + 26);
  }
  let output = '';
  for (let i = 0; i < str.length; i++) {
    let char = str[i];
    if (char.match(/[a-z]/i)) {
      let code = str.charCodeAt(i);
      if (code >= 65 && code <= 90) {
        char = String.fromCharCode(((code - 65 + amount) % 26) + 65);
      } else if (code >= 97 && code <= 122) {
        char = String.fromCharCode(((code - 97 + amount) % 26) + 97);
      }
    }
    output += char;
  }
  return output;
};

const symbolCipher = (str) => {
  const symbols = {
    'i': '!',
    '!': 'i',
    'l': '1',
    '1': 'l',
    's': '$',
    '$': 's',
    'o': '0',
    '0': 'o',
    'a': '@',
    '@': 'a',
    'e': '3',
    '3': 'e',
    'b': '6',
    '6': 'b'
  }

  let output = '';
  for (let i = 0; i < str.length; i++) {
    let char = str.toLowerCase()[i];

    if (symbols[char]) {
      output += symbols[char]
    } else {
      output += char;
    }
  }
  return output;
}

const reverseCipher = (sentence) => {
  let words = sentence.split(' ');
  for (let i = 0; i < words.length; i++) {
    words[i] = words[i].split('').reverse().join('');
  }
   return words.join(' ');
};


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

While my program works I really would like to figure out why I keep having this issue. If there is any other info I can share please tell me so I can post it.

Thanks in advance

Hi @giselacepeda34900865

Do you notice a difference?

2 Likes

Drats… I totally missed that. Thanks to bringing it to attention! I feel silly now

1 Like

No worries. With a neglected camelCase you’re in the best company :slightly_smiling_face: