scrimba
Frontend Career Path
Getting hired
JavaScript Interview Challenges
Challenge - Emojify!
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

AboutCommentsNotes
Challenge - Emojify!
Expand for more info
index.js
run
preview
console
/*  Emojify!

Popular services like Slack and Github allow for emoji shortscodes, meaning
they will detect when a word in a sentence begins and ends with a colon (:)
and automatically replace that word with an emoji.

These shortcodes allow users to add an emoji to their messages by typing a
code rather than searching for an emoji from a list.

For example, typing :smile: will replace that text with ๐Ÿ˜Š

*/

const emojis = {
"smile": "๐Ÿ˜Š",
"angry": "๐Ÿ˜ ",
"party": "๐ŸŽ‰",
"heart": "๐Ÿ’œ",
"cat": "๐Ÿฑ",
"dog": "๐Ÿ•"
}

/* 1. Write a function that checks if a lowercase word starts and
ends with a colon. If it does, remove the colons and
look up the word in the emoji object. If the word is in the
emojis object, return the corresponding emoji.
If it isn't, return the original word.

Example input: ":party:"
Example output: ๐ŸŽ‰

Example input: ":flower:"
Example output: "flower"

Example input: "elephant"
Example output: "elephant"
*/

function emojifyWord(word){
return;
}

/* 2. Write a function to find any emoji shortcodes in a phrase.
Your function should map over each word in the phrase, emojify any word
that begins and ends with a colon, then return the emojified phrase.
Feel free to use your emojify function from the previous exercise!

Example input: "I :heart: my :cat:"
Example output: "I ๐Ÿ’œ my ๐Ÿฑ"

Example input: "I :heart: my elephant"
Example output: "I ๐Ÿ’œ my elephant"
*/

function emojifyPhrase(phrase){
return;
}



// console.log(emojifyWord(":heart:"));
// console.log(emojifyWord(":flower:"));
// console.log(emojifyWord("elephant"));

// console.log(emojifyPhrase("I :heart: my :cat:"));
// console.log(emojifyPhrase("I :heart: my :elephant:"));
Console
/index.html
-2:40