You are viewing a single comment's thread from:

RE: 'Making A Game' - Learning to Code

in Learn to Code2 months ago

The error must be around here, I think.

 <li><a href="#" onclick="exploreTown('north')">Go North</a>li>
        <li><a href="#" onclick="exploreTown('east')">Go East</a>li>
        <li><a href="#" onclick="exploreTown('south')">Go South</a>li>
        <li><a href="#" onclick="exploreTown('west')">Go West</a>li>
function exploreTown(x, y) {
    const currentLocation = `${x}_${y}`; // Current location coordinates
    if (gameMap[currentLocation]) {
        // Location exists
        displayLocation(currentLocation);
    } else {
        console.log('Invalid location.');
    }
}```
Sort:  

I'll double check it in a little bit.

I'm about to sit down after dinner and play around with this to see if I can correct my error.