in line 10 you pass the function reference of the today function. What you want to use for the property access is the value the function returns... therefore, just execute the function by beating its but with ()... ;-) ...give it a kick to get a kick out of it...
var days = {
Monday: {hour: 6, minute: 30},
Tuesday: {hour: 7, minute: 0},
};
var today = function() {
return "Tuesday"; // simplified for this example (yes string is just perfect)
};
console.log(days[today()].hour);
Thank you very, very much indeed. This makes sense now, but I couldn't find any examples which illustrated it in usual places (W3, StackOverflow, etc.). Probably wasn't searching for the right terms.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
@user101594
in line 10 you pass the function reference of the today function. What you want to use for the property access is the value the function returns... therefore, just execute the function by beating its but with ()... ;-) ...give it a kick to get a kick out of it...