Learn Basic JavaScript by Building a Role Playing Game - Objects and Locations

I don’t know if it has been covered but my question is about the objects portion of this project. When declaring the variable “locations” in the lesson, we use “locations” not “location” . Then in future steps we call “location” in the update function. Are “locations” and “location” two independently different things, or does the JavaScript understand the grammatical rules pertaining to multiples where we add the s when referring to the whole array and take it away when pulling one item from it?

Ex.

const locations = [
{
name: “town square”,
“button text”: [“Go to store”, “Go to cave”, “Fight dragon”],
“button functions”: [goStore, goCave, fightDragon],…

function update(location) {
button1.innerText = location[“button text”][0];
button2.innerText = location[“button text”][1];
button3.innerText = location[“button text”][2];

Welcome to the forum @thomas.hevener

Here is a recent post about location and locations you may find helpful.

Happy coding

there is no link between the two variables, JavaScript doesn’t understand grammar, the link is created when you call the update function passing in one of the elements of locations, like update(locations[0]) (which I think happens in a future step)

Thanks guys! I fully get it now. I know this is a beta, and that was a point of confusion for me so i didn’t know if others had the same issue.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.