Magic Square problem solved with JavaScript