Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
first_word solution in Uncategorized category for First Word by Jon_Red
import assert from'assert';
function firstWord(text:string):string{return text.trim().match(/[^\s,.]+/)[0]}
// self-checks
assert.equal(firstWord('Hello world'),'Hello')
assert.equal(firstWord(' a word '),'a')
assert.equal(firstWord("don't touch it"),"don't")
assert.equal(firstWord('greetings, friends'),'greetings')
assert.equal(firstWord('... and so on ...'),'and')
assert.equal(firstWord('hi'),'hi')
July 16, 2020
Comments: