1

Is this even possible?

<h3 id="question">Some text</h3>

...

var theQuestion = document.querySelector('#question').innerText;
...
self.newData.theQuestion = [];

Saves: theKey : {"theQuestion":[]}

Trying to achieve: theKey : {"Some Text":[]}

Edit: See screenshot

screenshot

2
  • I'm not really get your purpose, The localstorage either the key or the value are just plain string, it can't be dynamically change it self.But you can redefine it or you can transform it when getting the value Commented Feb 4, 2016 at 16:05
  • Yes, you haven't understood the question. Look at the h3, the var 'theQuestion' and the screenshot. Commented Feb 4, 2016 at 16:09

1 Answer 1

1

Found it.. Didn't think it would be this easy:

self.newData[theQuestion]

Can close this question if you wish moderator.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.