Hello, i’m wondering if its possible to add js code to js code using js
I installed annyang .js so i have this code:
if (annyang) {
// Let's define a command.
var commands = {
'hello': function() { alert('Hello world!'); }
};
// Add our commands to annyang
annyang.addCommands(commands);
// Start listening.
annyang.start();
}
Which works perfect, because if i open the page, and i say the hello word, it prompts the alert. But i want to add that “words” dynamically not like pre-defined values.
Something like:
Lets say i have a button, and 2 inputs.
When i press the button, i want to add here:
var wordrec = properties.word;
var commands = {
wordrec: function() { alert('Hello world!'); }
};
properties.word is the field that hold the “word”, im trying to pass that to the function, but seems its not getting the wordrec value.
Its possible to use a variable in a function?
Edit:
The reason why i think its not getting the wordrec variable is because my editor is not showing me the blue on the wordrec word, inside the commands: