Exercise 11: Storage with Version

Problem Statement

Function `setVersioned(key, value, version)` banao jo value ko version ke saath store kare. Example: setVersioned("data", {x: 1}, "v1")

Sample Output:

setVersioned("data", {x: 1}, "v1")
// Stores with version

Solution

const setVersioned = (key, value, version) => {
  localStorage.setItem(key, JSON.stringify({value, version}));
};

Explanation

Overall Goal:

  • Value ko version ke saath store karna.

Real world:

  • Data migration: version tracking.
  • Compatibility: version checks.