function calcular() { var x = document.getElementById("num1").value; var y = document.getElementById("num2").value; var gx = x; var gy = y; var w; while (y != 0) { w = x % y; x = y; y = w; } var mcm = gx * gy / x; document.getElementById("resultado").value = mcm; } function calcularBien() { var x = document.getElementById("num1").value; var y = document.getElementById("num2").value; document.getElementById("resultado").value = minimoComunMultiplo(x, y); } function minimoComunMultiplo(x, y) { var gx = x; var gy = y; var w; while (y != 0) { w = x % y; x = y; y = w; } return gx * gy / x; } var frase="Juanito"; console.log(alReves('Viva la Pepa')); function alReves(frase){ return frase.split('').reverse().join(''); }