Skip to content

Commit

Permalink
➕ feat: problems
Browse files Browse the repository at this point in the history
  • Loading branch information
linder3hs committed Mar 7, 2024
1 parent d6cfd84 commit 73c8617
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions semana-6/problemas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
Revertir una cadena
Crea una función que tome una cadena como entrada y devuelva una nueva cadena con los caracteres en orden inverso.
Ejemplo
hola = aloh
mundo = odnum
*/

function invertirCadena(texto) {
// primero validamos si el parametro texto es una cadena
if (typeof texto !== "string") {
return "Unicamente aceptamos textos";
}

return texto.split("").reverse().join("");
}

invertirCadena(100); // 001
invertirCadena(true);
invertirCadena("hola mundo");

0 comments on commit 73c8617

Please sign in to comment.