From 30569037cae28ad3453aaa9a33a39111ef837e19 Mon Sep 17 00:00:00 2001 From: Gurbinder Singh Date: Sat, 23 Sep 2023 12:55:08 +0200 Subject: [PATCH] Fix bug --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 8b1f578..61682cb 100644 --- a/index.js +++ b/index.js @@ -56,7 +56,7 @@ function determineLocalStorageSize(upperBound, lowerBound) { const bailOut = 100; for (let i = 0; i < bailOut && lowerBound < upperBound; i++) { - const testBound = lowerBound + Math.floor((upperBound - lowerBound) / 2); + const testBound = lowerBound + Math.ceil((upperBound - lowerBound) / 2); const testString = createStringWithLength(testBound); try { @@ -72,7 +72,7 @@ function determineLocalStorageSize(upperBound, lowerBound) { } } console.info(`Size of local storage: ${upperBound} characters`); - return upperBound; + return lowerBound; } document.getElementById("test-start")?.addEventListener("click", () => { @@ -89,7 +89,7 @@ document.getElementById("test-start")?.addEventListener("click", () => { document.getElementById("result").innerHTML = `Calculating.`; let result = determineLocalStorageSize(upperBound, lowerBound); - + document.getElementById( "result" ).innerText = `The maximum size of local storage is ${result} characters.`;