-3

Example,

function setLocalStorage(key, value){
            localStorage.key = value;
}

i want the key param to be the key, but if i code like this

the "key" string becomes the key.

Suhail Patel
  • 13,644
  • 2
  • 44
  • 49
Canna
  • 3,614
  • 5
  • 28
  • 33

1 Answers1

2

If you are looking to add a key to an object with a value:

function setLocalStorage(key, value){
    localStorage[key] = value;
}
C. S.
  • 805
  • 6
  • 6