Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
ES6, regex solution in Clear category for [old] Three Words by matejm
'use strict';
const assert = require('assert');
const threeWords = (text) => /(?:\b[a-zA-Z]+\b\s?){3}/.test(text);
if (!global.is_checking) {
assert.strictEqual(
threeWords('Hello World hello'),
true,
'1st example',
);
assert.strictEqual(
threeWords('He is 123 man'),
false,
'2nd example',
);
assert.strictEqual(
threeWords('1 2 3 4'),
false,
'3rd example',
);
assert.strictEqual(
threeWords('bla bla bla bla'),
true,
'4th example',
);
assert.strictEqual(
threeWords('Hi'),
false,
'Letters',
);
}
Dec. 8, 2018