JavaScript
const res = document.querySelector("#resultado");
numeroAleatorio = (a,b) => {
  const ntotal = b-a+1;
  res.innerHTML = (Math.floor(Math.random() * ntotal + a));
};
HTML
<p>Clique os botões seguidamente.</p>
<button type="button" onclick="numeroAleatorio(2,12)">Gerar aleatório [2-12]</button>
<button type="button" onclick="numeroAleatorio(15,55)">Gerar aleatório [15-55]</button>
<button type="button" onclick="numeroAleatorio(10,100)">Gerar aleatório [17-99]</button>
<button type="button" onclick="numeroAleatorio(0,10)">Gerar aleatório [0-10]</button>
<div id="resultado"></div>

Clique os botões seguidamente.