JSFiddle - React, Tailwind, and code Playground

HTML

<div id='outputTxt'></div>

JavaScript

a = 0.00002123501;
writeScientificNum(a, 3);

function writeScientificNum(p_num, p_precision) {
  var n = Math.round(Math.log10(a));
	var m = (p_num * (Math.pow(10,Math.abs(n)))).toFixed(p_precision);
	document.getElementById("outputTxt").innerHTML = m.toString() + ' x 10<sup>' + n.toString() + '</sup>';
}