Update core.js

Fix for loop