You can use localStorage
localStorage.setItem('myCat', 'Tom'); //сохранить localStorage.getItem('myCat'); //взять
According to your example:
var i=+(prompt("сколько всего слов ?")); while (n<=i){ var slovo=prompt(); var otvet=prompt(); localStorage.setItem(slovo, otvet); n++; }
And then when you call localStorage.getItem('english'); will return "English". Naturally, if it was previously introduced.
There are more cookies . The links have examples of use.
UPDATE by comment
You need to add localValue to the loop body:
var i = (prompt("сколько всего слов ?")); var n = 1; while (n <= parseInt(i)) { var slovo = prompt("Введите слова:"); var otvet = prompt("Введите перевод:"); localStorage.setItem(slovo, otvet); n++; } n1 = 1; while (n1 <= i) { var localValue = localStorage.getItem(slovo); var answer = prompt(localValue); if (answer === localValue) alert("Правильно"); n++; }
If you are working in Google Chrome, you can click F12 -> Application -> (on the left in the Storage section) Local Storage -> your domain. There will be data stored in your local repository. I don’t know exactly how to open Firefox, but about the same.