Message Mixer: Type error

https://www.codecademy.com/paths/create-a-back-end-app-with-javascript/tracks/bapi-javascript-objects-modules-and-browser-compatibility/modules/bapi-node-modules/projects/message-mixer-node

hello i’m doing the message mixer project but after step 5 i try the ‘node message-mixer.js caesar 4’ and it returns an error saying
"$ node message-mixer.js caesar 4
/home/ccuser/workspace/modules-message-mixer/encryptors.js:7
for (let i = 0; i < str.length; i++) {
^

TypeError: Cannot read property ‘length’ of undefined
at Object.caesarCipher (/home/ccuser/workspace/modules-message-mixer/encryptors.js:7:26)
at Object. (/home/ccuser/workspace/modules-message-mixer/message-mixer.js:3:33)
at Module._compile (module.js:571:32)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)
at startup (bootstrap_node.js:151:9)"
i don’t understand why it can’t read a built in property and keeps throwing the error i really need your help guys

Hi @cloud8486972927
Welcome to the forums!

That means the program cannot find the variable which length you’re trying to get. The variable ‘str’ is undefined. Either because you have a typo, you forgot to declare it, or you haven’t imported it correctly.
So trace back the variable ‘str’. If you still can’t find out, why it cannot be found, you need to provide more code. Please make sure to format it according to this guideline:
https://discuss.codecademy.com/t/how-do-i-format-code-in-my-posts/28351

ok thanks i’ll check it out again and get back to you

1 Like