Hello buddies, i need ur help in resolving problem in this exercise https://www.codecademy.com/courses/introduction-to-javascript/projects/message-mixer
This is my ERROR
/home/ccuser/workspace/intermediate-javascript_messageMixer/messageMixer.js:66
exports.countCharacter = countCharacter;
^
ReferenceError: countCharacter is not defined
at Object.<anonymous> (messageMixer.js:66:10)
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
at Object.<anonymous> (/home/ccuser/node_modules/babel-cli/lib/_babel-node.js:172:7)
This is my code in the MeassageMixer.js
const MessageMixer = {};
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("");
};
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);
};
function encode(string) {
let replacementObject = { "a": "@", "s": "$", "i": "!", "o":"0" };
for (let key in replacementObject) {
string = MessageMixer.replaceAllOccurrences(string, key, replacementObject[key]);
}
return string;
};
function palindrome(str) {
return `${str} ${MessageMixer.reverseWord(str)}`;
};
MessageMixer.pigLatin = function(sentence, character){
return sentence.split(' ').join(character + ' ');
};
export default MessageMixer;
export { countCharacter, capitalizeFirstCharacterOfWords, reverseWord, reverseAllWords, replaceFirstOccurence, replaceAllOccurrences, encode, palindrome, pigLatin };
This is my code in Message.js
const MessageMixer = require('./messageMixer.js');
import { countCharacter, capitalizeFirstCharacterOfWords, reverseWord, reverseAllWords, replaceFirstOccurence, replaceAllOccurrences, encode, palindrome, pigLatin} from './messageMixer';
function displayMessage() {
console.log(countCharacter('What is the color of the sky?', 't'));
console.log(capitalizeFirstCharacterOfWords('What is the color of the sky?'));
console.log(reverseWord('What is the color of the sky?'));
console.log(reverseAllWords('What is the color of the sky?'));
console.log(replaceFirstOccurence('What is the color of the sky?', 'sky', 'water'));
console.log(encode('What is the color of the sky?'));
console.log(pigLatin("What is the color of the sky?","ay "));
console.log(palindrome("What is the color of the sky?"));
}
displayMessage();