Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7802867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:23:16+00:00 2026-06-02T01:23:16+00:00

Im learning javascript right now, so this might be a really newb question! I

  • 0

Im learning javascript right now, so this might be a really newb question! I googled it, but didnt found what I was looking for, maybe I just didnt googled the right thing, but yeah…Oh im not using any plug-ins for cookies.

I have a cookie named “country”, the value is the user’s country code, like US, CA, UK, AU or FR…
I want to display a block of content only if the country is, let’s say DE, ES, AT, IT or NL.

The logic of what im looking for: if cookie “country” exist and country == one of the country in my array…

Im thinking about something like… But that is obviously too simple and not working 🙂

var countryArray = new Array["DE", "ES", "AT", "IT", "NL"];

if( $.cookie('country') && $.cookie('country') == countryArray ) { alert("working"); }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T01:23:19+00:00Added an answer on June 2, 2026 at 1:23 am

    You could use indexOf for new browsers:

    countryArray.indexOf($.cookie('country')) > -1
    

    Also , instead of

     countryArray = new Array["DE", "ES", "AT", "IT", "NL"];
    

    you need to write:

     countryArray = ["DE", "ES", "AT", "IT", "NL"];
    

    UPDATE: For old browsers include this script in your js:

     Array.prototype.indexOf = Array.prototype.indexOf || function( value, startIndex ){
         var i = startIndex || 0;
         for(; i < this.length; ++i){
             if( value === this[i] ){
                 return i;
             }          
         }
         return -1;
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I do not know javascript right now but I am planning on learning it.
I'm just learning JavaScript right now, so please do try and explain with that
Right now, I'm learning Python and Javascript, and someone recently suggested to me that
I'm learning JavaScript right now, quite a task being new to both the syntax
I am learning jQuery right now and am looking to validate form fields with
I'm learning TDD (in Javascript), and I wanted to know, what is the right
I am learning how to create a website using ASP.NET & C#. Right now
So forgive me, I'm just starting learning Javascript, I don't even know if this
I'm just now learning about file tasks in Rake. I have 100s of javascript
I've used this code for(var i=0;i++;) in my javascript code. How ever i'm learning

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.