Add forEach loop to magic.js