Challenge: Write a function that takes a string as a parameter and returns the longest word in that string.
Conditions: The function name must be
longestString. If multiple words are the longest, the last one should be returned.
After you’ve sent your solution, the bot will run tests like
longestWord('Welcome to FCC!'); which should return
Here’s where I require your help. There are only so many challenges I can think of myself. If you have one or more ideas for a challenge, head over to https://icecub.nl/gitter/bobsbotty/ and follow the instructions to add your own challenge(s) to the bot (no registration required). After submission, you can track the status of your (and everyone elses) challenge(s) here.
Once the bot is live, I’ll update this thread about it. Thank you for your help and happy coding!
just wondering if these are going to be vanilla JS challenges?
Nice idea! Do you intend to publish the source code for the bot?
Feature request: the tests should be used to generate the Examples. This way, all the tests are visible to the person trying to solve the challenge.
EDIT: additional question: it appears that arrays must be JSON.stringified before output. I’m interested why this is – and does it apply to other data types, like Number?
EDIT: out of interest, why do the tests require semicolons at the end – JS autoinserts those at line breaks if needed? I ask because this means the tests do not conform with most style guides, are you stringing all the tests together on one line?
Object.entries isn’t supported. It’s very new, but is it possible to update?
Great idea! I like it very much.
The reason why the tests are not visible to the users, is to prevent them from cheating by hard coding return values. That’s why Codewars usually has a couple of visible tests, and a bunch of random (unpredictable) tests.
console.log();. Simply because there is no console. So if you try to output an array directly, it’ll just return the type “Array” instead of the array contents. The same goes for multple outputs like within a loop. If you tried that, the bot will only output the last loop. This is a good thing though. Otherwise users could loop something a thousend times and have the bot spam Gitter chat like crazy.
Question 2: No, that’s actually still there from the beta. The code is added on a new line of course.
Question 3: No it’s not possible to extend the engine’s capabilities. The bot itself runs on PHP using https://secure.php.net/manual/en/book.v8js.php. So I’m depending on that library. If I wanted to extend it, I’d have to change the code of that library and re-compile PHP with it. Which is simply out of the scope of my abilities.
Sorry, I forgot your question about releasing the bot’s source code. Like everything else here on FCC, I’ll follow the tradition of keeping everything we have available as open source. So yes, once the bot goes from beta to release stage, I’ll make its source available on Github.
As promissed, here’s the source of the bot: https://github.com/bjorno43/Bobsbotty
Appearently I spoke too soon about the option to update the V8 engine. The bot now supports ES2018