Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8227655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:11:52+00:00 2026-06-07T16:11:52+00:00

I was just learning about objects in school today and i know a function

  • 0

I was just learning about objects in school today and i know a function can be ran from inside an object, but the function is actually called a method, my method has an array and i like to get a particular destination to fire in the console.log by changing the global variable. Can this be done? All I’m getting is undefined at the last console.log -> ing at ” + worker.getLocation.myLocation); So in all reality I’m trying to change the global variable, var myLocation = 0 to output the different myLocation inside getLocation method.

var myLocation = 0

var worker = {
    realName:       "Willson",
    title:          "Assistant Maintenance Supervisor",
    maintenance:    true,
    vehicals:       ["2008 Dodge Caliber SRT-4", "2012 Jeep Wrangler Unlimited"      ],
    getLocation:    function () { 
        myLocation [0] = "Villas at Sunrise Mountain";
        myLocation [1] = "Reno Villas"; 
        myLocation [2] = "lost"; 
        myLocation [3] = "back home";
    }
};

console.log(worker.realName + " is a " + worker.title + " and drives a " + worker.vehicals[1] + " to work."); 

var destination = {
    property: ["Villas at Sunrise Mountain", "Reno Villas", "lost", "back home"]
};

console.log ("He sold his " + worker.vehicals[0] + "." + " Today he is working at " + worker.getLocation.myLocation);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:11:53+00:00Added an answer on June 7, 2026 at 4:11 pm
    var myLocation = 0
    
    var worker = {
        realName:       "Willson",
        title:          "Assistant Maintenance Supervisor",
        maintenance:    true,
        vehicals:       ["2008 Dodge Caliber SRT-4", "2012 Jeep Wrangler Unlimited"      ],
        getLocation:    function () { 
            var myLocationss = [];
            myLocationss [0] = "Villas at Sunrise Mountain";
            myLocationss [1] = "Reno Villas"; 
            myLocationss [2] = "lost"; 
            myLocationss [3] = "back home";
    
            return myLocations[myLocation];
    
        }
    };
    
    console.log(worker.realName + " is a " + worker.title + " and drives a " + worker.vehicals[1] + " to work."); 
    
    var destination = {
        property: ["Villas at Sunrise Mountain", "Reno Villas", "lost", "back home"]
    };
    
    console.log ("He sold his " + worker.vehicals[0] + "." + " Today he is working at " + worker.getLocation());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just learning about ORM's, and am wondering... if you have an object (a
Hey guys, just learning about composition of classes and ran into this error. Gradebook.h
I'm just learning about dynamic memory allocation, but there is one thing i'd like
I am just learning about LINQ to XML in all its glory and frailty,
I'm just learning about python. I'm fairly new. I have the following code that
I want to understand the actual theory behind types rather than just learning about
I just started learning about CSRF. As per OWASP CSRF Article CSRF is an
I've just started learning about Gimp scripting using Python, and was wondering, how do
I'm enrolled in Coursera ML class and I just started learning about neural networks.
I am in an introductory java course and we just started learning about inheritance.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.