Created
December 30, 2015 15:09
-
-
Save sethetter/ebf12e8ff5629840f50b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "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