I don't know how the correct structure would be to return a word to which the color of the middle letter is modified. I use a split to save all the words of a paragraph in an array, but I must modify each of these words, showing them with their middle letter in red. Investigating, I think I can use the slice method to modify the font color. This is my code:
HTML
<body>
<textarea id="text">JavaScript is the Programming Language for the Web, JavaScript can update and change both HTML and CSS, JavaScript can calculate, manipulate and validate data</textarea>
<div class="show">
<h3 id="txt"></h3>
</div>
<div class="control-box">
<button type="button" name="button" onclick="iniciar()">play</button>
</div>
</body>
</html>
Script
function iniciar(){
var texto = document.getElementById("text").value;
var palabras = texto.split(/[, ]+/);
var index = 0;
console.log(palabras);
function tester(){
document.getElementById("txt").innerHTML=palabras[index];
var timer = setTimeout(function(){
console.log(timer);
tester();
},550);
console.log(palabras[index]);
if (index>palabras.length-2){
clearTimeout(timer);
}
index++;
}
tester();
}