I apologize if my title is confusing in any way. I'm trying to figure out how to properly do this. I'm trying to create an object whos key:values are other objects. See the code below. I'm testing in the Chrome console.
If I just do Characters = CharactersFn("male");
or var Characters = CharactersFn("male");
by itself I can create the object from the CharactersFn()
function but when I try to do it via my whatAreYou()
function I get no results. How do I do this properly?
Note: I'm still learning and just trying to get a grasp on how to do things properly.
var Characters,
valueArr = [],
nameArr = [],
matchArr = [];
var CharactersFn = function (ans) { //Are you male or female?
"use strict";
if (ans === "male") {
Characters = {
47: aloy,
snake: snake,
drake: drake,
cloud: cloud
};
}
if (ans === "female") {
Characters = {
aloy: aloy,
bayonetta: bayonetta,
elizabeth: elizabeth,
ellie: ellie
};
}
return Characters;
};
function whatAreYou() {
"use strict";
var gender = prompt("0 or 1");
if (gender === 0) {
Characters = CharactersFn("female");
}
if (gender === 1) {
Characters = CharactersFn("male");
}
return Characters;
}