Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
CS - SLR - UpperCase, Concat, Slice, EndsWith, TernOp solution in Clear category for Correct Sentence by Taylor_Page
import assert from "assert";
function correctSentence(text: string): string {
// "Hard" correction with no check if string already meets standards
// - All strings will be set with UpperCase 1st Char and a period (.) last Char
return text[0].toUpperCase().concat(text.slice(1), text.endsWith(".") ? "" : ".")
}
console.log('Example:');
console.log(correctSentence('greetings, friends'));
// These "asserts" are used for self-checking
assert.equal(correctSentence('greetings, friends'), 'Greetings, friends.');
assert.equal(correctSentence('Greetings, friends'), 'Greetings, friends.');
assert.equal(correctSentence('Greetings, friends.'), 'Greetings, friends.');
console.log("Coding complete? Click 'Check' to earn cool rewards!");
May 27, 2020
Comments: