Javascript- Graph assignment