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 7626297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:18:25+00:00 2026-05-31T05:18:25+00:00

This has been bugging me for quite some time now. All I want to

  • 0

This has been bugging me for quite some time now. All I want to do is return a value from an array given its key, but use a variable (_interview) to choose what array to return from.

var utils = function () {

var _language = "";
var _interview = "";
var _base = "";

var _alerts = function (code) {

    var en = new Array(),
        fr = new Array();

    en[0] = "You must enter a value in the box before continuing.";
    fr[0] = "Vous devez entrer une sélection pour les options mises en évidence.";

    // I know _interview is returning the correct value of either "en" or "fr"
    // I have tried this[_interview][code] but I get property not defined at the index
    // How do I return the index from the right array?
};

return {

    lang : function () {

        _language = $("#language option:selected").val();
        var answer = confirm(_alerts(0)); // Call from here

    }
};
}();

$(document).ready(function ()
{
    utils.lang();
});
  • 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-05-31T05:18:25+00:00Added an answer on May 31, 2026 at 5:18 am

    Better to use 2D Array (deep object structure), and strings as keys instead of integer indexes

    var languages = {
        'en': {
            'string_key_1' : 'String For Key 1'
        },
        'fr': {
            'string_key_1' : 'Le String ...'
        }
    };
    

    To get values like

    var key = 'string_key_1';
    var translated_value = languages[_interview][key];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This has been bugging me for some time now. My problem is the following.
This has been bugging me for some time now, I will greatly appreciate the
This is has been bugging me for quite some time. >> nil.id (irb):2: warning:
This question has been bugging me for some time. I always picture launching my
This question has been bugging me for some time. I've already developed a couple
Have a question regarding something which has been bugging me for some time now.I'm
Hey all. Something which has been bugging me quite a bit recently is this
Good day to all of you... This has been bugging me for quite a
This has been bugging me for a long time now and I can't seem
This has been bugging me for more than two days now, so i thought

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.