Hi im having an error message when I run my code, here’s the link to the exercise: https://www.codecademy.com/paths/web-development/tracks/webdev-intermediate-javascript/modules/intermediate-javascript-modules/projects/message-mixer
I’m currently at step 8 and im having this error message:
/home/ccuser/workspace/intermediate-javascript_messageMixer/message.js:4
console.log(MessageMixer.countCharacter(“What is the color of the sky?”, “t”));
^
TypeError: Cannot read property ‘countCharacter’ of undefined
at displayMessage (message.js:2:15)
at Object. (message.js:10:1)
at Module._compile (module.js:571:32)
at loader (/home/ccuser/node_modules/babel-register/lib/node.js:158:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/ccuser/node_modules/babel-register/lib/node.js:168:7)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Function.Module.runMain (module.js:605:10)
at /home/ccuser/node_modules/babel-cli/lib/_babel-node.js:171:48
also here’s my code from messageMixer.js:
MessageMixer.countCharacter = function countCharacter(inputString, inputCharacter) {
let count = 0;
let string = inputString.toLowerCase();
let character = inputCharacter.toLowerCase();
for (let i = 0; i < string.length; i++) {
if (string[i] === character) {
count++;
}
}
return count;
};
MessageMixer.capitalizeFirstCharacterOfWords = function capitalizeFirstCharacterOfWords(string) {
let arr = string.split(" “);
for (let i = 0; i < arr.length; i++) {
let word = arr[i];
arr[i] = word[0].toUpperCase() + word.substring(1);
}
return arr.join(” ");
};
MessageMixer.reverseWord = function reverseWord(word) {
return word.split("").reverse().join("");
};
MessageMixer.reverseAllWords = function reverseAllWords(sentence) {
let words = sentence.split(" “);
for (let i = 0; i < words.length; i++) {
words[i] = MessageMixer.reverseWord(words[i]);
}
return words.join(” ");
};
MessageMixer.replaceFirstOccurence = function replaceFirstOccurence(string, toBeReplaced, replaceWith) {
return string.replace(toBeReplaced, replaceWith);
};
MessageMixer.replaceAllOccurrences = function replaceAllOccurrences(string, toBeReplaced, replaceWith) {
return string.split(toBeReplaced).join(replaceWith);
};
MessageMixer.encode = function encode(string) {
let replacementObject = { “a”: “@”, “s”: “$”, “i”: “!”, “o”:“0” };
for (let key in replacementObject) {
string = MessageMixer.replaceAllOccurrences(string, key, replacementObject[key]);
}
return string;
};
const MessageMixer = {};
displayMessage();
module.exports = MessageMixer;
and here’s the code from message.js:
function displayMessage() {
console.log(MessageMixer.countCharacter(“What is the color of the sky?”, “t”));
console.log(MessageMixer.capitalizeFirstCharacterOfWords(“What is the color of the sky?”));
console.log(MessageMixer.reverseWord(“What is the color of the sky?”));
console.log(MessageMixer.reverseAllWords(“What is the color of the sky?”));
console.log(MessageMixer.replaceFirstOccurence(“What is the color of the sky?”, “sky”, “water”));
console.log(MessageMixer.encode(“What is the color of the sky?”));
}
displayMessage();
const MessageMixer = require(’./messageMixer.js’);