Generate a random number between two numbers using JavaScript

const x = 1;
const y = 6;

console.log(~~(Math.random() * y) + x);
Input
Output