Added most of ch-05 from Eloquent JS, 2nd ed