Redoing the coding exercise in angular.js