Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Gurbinder Singh committed Sep 23, 2023
1 parent 8e17cfb commit 3056903
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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", () => {
Expand All @@ -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.`;
Expand Down

0 comments on commit 3056903

Please sign in to comment.