how to add variable to local storage in javascript

JavaScript
localStorage.setItem('key', 'value')
Source

Also in JavaScript: