cookie factory in vanilla javascript with johnny wu