JSFiddle - React, Tailwind, and code Playground
JavaScript
//i'm trying to enter "one" and have "ONE" return
//right now, i get the term, but not that value
var dict = {
"first level": {
"one": "ONE",
"two": {
"three sub": "THREE SUB"
},
"four": "FOUR"
}
};
function lookup(obj, term){
var A= [];
for(var p in obj){
if(obj.hasOwnProperty(p)){
if(term && typeof term=='object'){
A[A.length]= '{' + arguments.callee(term) + '}';
}
//else A[A.length]= [p+':'+term.toString()];
//how do i get the value of "term" below?
else A[A.length]= [term];
}
}
return A;
}
//here is where i pass the "term" variable
var s=lookup(dict, "one").join('\n');
alert(s)