Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Add AMD example
Browse files Browse the repository at this point in the history
  • Loading branch information
jedfoster committed Oct 1, 2015
1 parent d396de8 commit c5bc034
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions amd/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require(['./greetings', './audience'], function(greetings, audience) {
console.log(greetings.random() + audience());
});
8 changes: 8 additions & 0 deletions amd/audience.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function audience() {
arr = ['World', 'Peeps', 'Earthlings', 'my fellow Americans'];
return arr[Math.floor(Math.random() * arr.length)]
}

define(function() {
return audience;
});
13 changes: 13 additions & 0 deletions amd/greetings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
define(function() {
return {
english: 'Hello ',
french: 'Bonjour ',
german: 'Hallo ',
spanish: 'Hola ',

random: function() {
var arr = ['english', 'french', 'german', 'spanish'];
return this[arr[Math.floor(Math.random() * arr.length)]]
}
};
});

0 comments on commit c5bc034

Please sign in to comment.