0

I have a small bit of code that is really giving me a headache. All it needs to do is get a location (in this case an array representing a longitude and latitude).

planner.js:

var plan = function (lawnmower, yard) {
var currentPos = lawnmower.position;
alert(currentLong);

lawnmower:

var longitude = homeLongitude, latitude = homeLatitude;
var getPosition = function() {
    return [longitude, latitude];
};
that.position = getPosition;

When the alert gets called it returns getPosition after the equal sign.

Heres a pic

I'm fairly novice at JS.

1
  • You are assigning the value of the function as opposed to assigning the result of it's invocation, which is represented by the (). Commented Jul 8, 2015 at 21:19

1 Answer 1

3

You forgot the () when you call getPosition, so instead of assigning the result to that.position you're assigning the entire function:

that.position = getPosition(); //parenthesis!
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.