JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" size="15" id="texto" value="EsTo Es UNA PrUeBa.">
<button onclick="obtener_capitales()">Ver</button>

JavaScript

var arr = [];

function obtener_capitales(){ 
var text = document.getElementById("texto").value;

for(i=0; i<text.length; i++){
if(text.charCodeAt(i) >= 65 && text.charCodeAt(i) <= 90)
arr.push(text.charAt(i));
}
alert(arr);
arr = [];
}