dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
1.7 KiB
1.7 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 6a26df3e2988bcdded204894 | Challenge 358: Emoji Translator | 28 | challenge-358 |
--description--
Given a string of emojis, return the phrase using the following table:
| Emoji | Word |
|---|---|
| 👶 | "baby" |
| 🐱 | "cat" |
| 🐕 | "dog" |
| 🐟 | "fish" |
| 🥵 | "hot" |
| 🧊 | "ice" |
| 🪨 | "rock" |
| 🦈 | "shark" |
| 🍲 | "soup" |
| ⭐ | "star" |
Return the words separated by spaces.
--hints--
getEmojiPhrase("🪨⭐") should return "rock star".
assert.equal(getEmojiPhrase("🪨⭐"), "rock star");
getEmojiPhrase("🥵🐕") should return "hot dog".
assert.equal(getEmojiPhrase("🥵🐕"), "hot dog");
getEmojiPhrase("👶🦈") should return "baby shark".
assert.equal(getEmojiPhrase("👶🦈"), "baby shark");
getEmojiPhrase("⭐🐟") should return "star fish".
assert.equal(getEmojiPhrase("⭐🐟"), "star fish");
getEmojiPhrase("🧊🧊👶") should return "ice ice baby".
assert.equal(getEmojiPhrase("🧊🧊👶"), "ice ice baby");
getEmojiPhrase("🐱🐟🍲") should return "cat fish soup".
assert.equal(getEmojiPhrase("🐱🐟🍲"), "cat fish soup");
--seed--
--seed-contents--
function getEmojiPhrase(str) {
return str;
}
--solutions--
function getEmojiPhrase(str) {
const table = {
'👶': 'baby',
'🐱': 'cat',
'🐕': 'dog',
'🐟': 'fish',
'🥵': 'hot',
'🧊': 'ice',
'🪨': 'rock',
'🦈': 'shark',
'🍲': 'soup',
'⭐': 'star',
};
return [...str].map(emoji => table[emoji]).join(' ');
}