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 |
|---|---|---|---|
| 68ffb91507a5b645769328c9 | Challenge 106: Message Validator | 28 | challenge-106 |
--description--
Given a message string and a validation string, determine if the message is valid.
- A message is valid if each word in the message starts with the corresponding letter in the validation string, in order.
- Letters are case-insensitive.
- Words in the message are separated by single spaces.
--hints--
isValidMessage("hello world", "hw") should return true.
assert.isTrue(isValidMessage("hello world", "hw"));
isValidMessage("ALL CAPITAL LETTERS", "acl") should return true.
assert.isTrue(isValidMessage("ALL CAPITAL LETTERS", "acl"));
isValidMessage("Coding challenge are boring.", "cca") should return false.
assert.isFalse(isValidMessage("Coding challenge are boring.", "cca"));
isValidMessage("The quick brown fox jumps over the lazy dog.", "TQBFJOTLD") should return true.
assert.isTrue(isValidMessage("The quick brown fox jumps over the lazy dog.", "TQBFJOTLD"));
isValidMessage("The quick brown fox jumps over the lazy dog.", "TQBFJOTLDT") should return false.
assert.isFalse(isValidMessage("The quick brown fox jumps over the lazy dog.", "TQBFJOTLDT"));
--seed--
--seed-contents--
function isValidMessage(message, validator) {
return message;
}
--solutions--
function isValidMessage(message, validation) {
const words = message.split(" ");
if (words.length !== validation.length) return false;
for (let i = 0; i < words.length; i++) {
if (words[i][0].toLowerCase() !== validation[i].toLowerCase()) {
return false;
}
}
return true;
}