Hello

Lets say in the localStorage object I have the following:

Apple = red
Potato = brown
Gum = blue

And I want to search thru it for the word Potato and then get its value (brown).

How could I do this?

Im thinking:

for (var i=0;i<localStorage.length();i++)
{
    if (localStorage[i]=="Potato")
    {
    var somevariable=localStorage[i].value();
    break;
    }
}

Forgive sintaxis errors as I just thought it up in 15 seconds.

Recommended Answers

All 2 Replies

Use a 2D array ..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.