JSFiddle - React, Tailwind, and code Playground

by Diablo Rodriguez

HTML

<button onclick="mostrarAlerta('Mi Texto Personalizado FUNCION');">
  Llamar Alerta Mediante Funcion
</button>

<button onclick="alert('Mi Texto Personalizado DIRECTAMENTE');">
  Llamar Alerta Directamente
</button>

JavaScript

function mostrarAlerta(str){// el parametro creado por nosotros llamado "str" es el texto a mostrar, y será establecido cada vez que llamemos la función.
alert(str);// Aqui estamos declarando que el texto a mostrar en la alerta será el texto que establescamos al llamar la función.
}