Your solution mostly works, but a simpler one takes advantage of combining computed property keys and compact method syntax:
https://gist.github.com/raganwald/18f8c179101cfd93c291