JSFiddle - React, Tailwind, and code Playground

JavaScript

function getLeftStorageSize() {
  var itemBackup = localStorage.getItem("");
  var increase = true
  var data = "1"
  var totalData = ""
  var trytotalData = ""
  while (true) {
    try {
      trytotalData = totalData + data
      localStorage.setItem("", trytotalData);
      totalData = trytotalData;
      if (increase) data += data
    } catch (e) {
      if (data.length < 2) {
        //var storageSize = localStorage.getItem("").length
        //console.log("LIMIT REACHED: ", totalData.length);
        //console.log(e);
        break;
      }
      increase = false
      data = data.substr(data.length / 2)
    }
  }
  localStorage.setItem("", itemBackup);

  return totalData.length
}

document.write("calculating..")
var storageLeft = getLeftStorageSize()
console.log(storageLeft)
document.write(storageLeft)