Advertisement
Guest User

Untitled

a guest
Oct 17th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. function contarletras2(){
  2. cadena=document.getElementById("palabras").value;
  3. caract=document.getElementById("caracter").value;
  4.  
  5. cuenta = 0;
  6. posicion = cadena.indexOf(caract);
  7. while ( posicion != -1 ) {
  8. cuenta++;
  9. posicion = cadena.indexOf(caract,posicion+1);
  10. }
  11. valor= "Hay "+cuenta+ " letras " +caract ;
  12.  
  13.  
  14. document.getElementById("resultado").innerHTML=valor;
  15.  
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement