Files
wehub-resource-sync 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
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

1.4 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
68f6587287ad1f4ad39b0c7c Challenge 90: Character Limit 28 challenge-90

--description--

In this challenge, you are given a string and need to determine if it fits in a social media post. Return the following strings based on the rules given:

  • "short post" if it fits within a 40-character limit.
  • "long post" if it's greater than 40 characters and fits within an 80-character limit.
  • "invalid post" if it's too long to fit within either limit.

--hints--

canPost("Hello world") should return "short post".

assert.equal(canPost("Hello world"), "short post");

canPost("This is a longer message but still under eighty characters.") should return "long post".

assert.equal(canPost("This is a longer message but still under eighty characters."), "long post");

canPost("This message is too long to fit into either of the character limits for a social media post.") should return "invalid post".

assert.equal(canPost("This message is too long to fit into either of the character limits for a social media post."), "invalid post");

--seed--

--seed-contents--

function canPost(message) {

  return message;
}

--solutions--

function canPost(message) {
  if (message.length <= 40) {
    return "short post"
  } else if (message.length <= 80) {
    return "long post"
  } else {
    return "invalid post"
  }
}