JSFiddle - React, Tailwind, and code Playground
by Matt Ball
HTML
<select id="language">
<option value="en">English</option>
<option value="fr">French</option>
</select>
JavaScript
var utils = function() {
var _language = "";
var _interview = "";
var _base = "";
var _alerts = function(code) {
var messages = {
en: ["You must enter a value in the box before continuing."],
fr: ["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 messages[_language][code];
};
return {
lang: function() {
_language = $("#language").val();
var answer = confirm(_alerts(0)); // Call from here
}
};
}();
$(document).ready(function() {
utils.lang();
});