lunes, 31 de enero de 2022

FUNCIONES TIPO TEXTO EN JAVASCRIPT

 EJERCICIO PALINDROMO:


<html>

<script>

 function procesar()

{

    var v_texto= document.getElementById("nombre").value;

n=v_texto.length;  // total caracteres

   // alert (n);

var v_res="";

for(i=n-1;i>=0;i--)

{

   c=v_texto.charAt(i);

    v_res=v_res + c;

//alert (v_res);

}

resultado.value=v_res;

if(v_res==v_texto)

{

   alert ("PALINDROMO");

}

else

{

   alert ("NO PALINDROMO");

}

}

</script>

<body>

 <form name="form1" method="post" action="">

 <center>

 <h2> funciones tipo TEXTO- PALINDROMO</h2>

 <h3>


nombre:

<input type="text" name="nombre" id="nombre"> <p>

resultado:

<input type="text" name="resultado" id="resultado"> <p>

<input type="button" onclick="procesar ()" name="r"

    id="r" value="procesar"> <p>

</h3> 

</center>


</form>

</body>

</html>


No hay comentarios:

Publicar un comentario