Skip to content

Instantly share code, notes, and snippets.

@sethetter
Created December 30, 2015 15:09
Show Gist options
  • Save sethetter/ebf12e8ff5629840f50b to your computer and use it in GitHub Desktop.
Save sethetter/ebf12e8ff5629840f50b to your computer and use it in GitHub Desktop.
{
"name": "Kevin Falting",
"age": 1000,
"friends": [ "Seth", "Amanda" ],
"goals": [
{
"title": "Build bot plugin",
"completed": false
},
{
"title": "Do something else",
"completed": true
}
]
}
kevinsData.foo.bar.baz[0].title.shortVersion;
kevinsData.goals[0].title;
var dataString = JSON.stringify(kevinsData);
robot.brain.store('kevinfalting', dataString);
var dataString = robot.brain.get('kevinfating');
var kevinsData = JSON.parse(dataString);
kevinsData.goals.push({
title: 'New goal',
completed: false
});
var number = numberOfGoalsCompleted(kevinsData.goals);
function numberOfGoalsCompleted(goals) {
var count = 0;
goals.forEach(function(goal) {
if (goal.completed) count++;
});
return count;
}
function showGoals(userData) {
robot.say('Your goals:');
userData.goals.forEach(function(goal, idx) {
robot.say(idx + '. ' + goal.title + ' (' + goal.completed + ')');
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment