JSFiddle - React, Tailwind, and code Playground

by lenny86

JavaScript

const text = "greetings, friends";

const correctSentence = (text) => {
	let s = [...text];
	s[0] = s[0].toUpperCase();
  s[s.length-1] === '.' ? null : s.push('.');
  return s.join('')
}

console.log(correctSentence(text))