Exercise 17: Storage Quota Check
Problem Statement
Function `checkStorageQuota()` banao jo available storage space check kare.
Example: checkStorageQuota() => {used: 1024, available: 5120000}
Sample Output:
await checkStorageQuota() => {used: 1024, available: 5120000}
// Returns storage usage infoSolution
const checkStorageQuota = async () => {
if (navigator.storage && navigator.storage.estimate) {
const estimate = await navigator.storage.estimate();
return {
used: estimate.usage || 0,
available: (estimate.quota || 0) - (estimate.usage || 0)
};
}
return {used: 0, available: 0};
};Explanation
Overall Goal:
- Storage quota check karna.
Real world:
- Quota management: space monitoring.
- Storage limits: quota checks.