Generate Random Fractions with JavaScript

generate a random fraction and add it to result when clicking a button

Demo

function randomFraction() {
  var result_html = document.getElementById("result");
  var random_number = Math.random();
  result_html.innerHTML = random_number;
  return random_number;
}

HTML

<div id='result' class='mb-3 alert alert-primary'>..</div>
<button onclick='randomFraction();' class='btn btn-primary'>randomFraction</button>

Result

..

Other Items in js

Welcome

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

❤👩‍💻🕹