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 8686901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:58:56+00:00 2026-06-12T22:58:56+00:00

I am trying to set up a javascript object with one of it’s items

  • 0

I am trying to set up a javascript object with one of it’s items being a function. I am doing a little bit of self reference and it is not working.

var onTimePoints = function($a, $b, $c, $lifeotr){

    $var1 = ($b - $a) / $c;
    $var2 = ($lifeotr - $a) / $var1;
    if($var2>$c)
    {
    $var2 = $c;
    }
    if($var2<0)
    {
    $var2 = 0;
    }
    $var2 = Math.round($var2);
    return $var2;
}
var lifeData ={
      min: 25000,
      max: 65000,
      otr: 56426,
      maxPoints:100,
      otp: onTimePoints(25000, 65000, 100, 56426),
      test: function(){
        alert(this.min);
      }
}

When I do conosle.log(lifeData.otp) it works.

When I replace the hard coded numbers with this.min, this.max, etc… it doesn’t work.

Here is an example of what doesn’t work:

var lifeData ={
  min: 25000,
  max: 65000,
  otr: 56426,
  maxPoints:100,
  otp: onTimePoints(this.min, this.max, this.maxPoints, this.otr),
  test: function(){
    alert(this.min);
  }
}

In this case console.log(lifeData.otp) returns NaN.

I am sure that I am just overlooking something. Appreciate if you know the issue.

  • 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-12T22:58:58+00:00Added an answer on June 12, 2026 at 10:58 pm

    You can’t do what you’re trying to do.

    Consider:

    var lifeData ={
      min: 25000,
      max: 65000,
      otr: 56426,
      maxPoints:100,
      otp: onTimePoints(25000, 65000, 100, 56426),
      otNewcomm: formula,
      test: function(){
        alert(this.min);
      }
    }
    

    or

    var min = 25000;
    var max = 65000;
    var otr = 56426;
    var maxPoints = 100;
    var lifeData ={
      min: min,
      max: max,
      otr: otr,
      maxPoints: maxPoints,
      otp: onTimePoints(min, max, maxPoints, otr),
      otNewcomm: formula,
      test: function(){
        alert(this.min);
      }
    }
    

    or

    function lifeData(min, max, otr, maxPoints)
    {
        this.min = min;
        this.max = max;
        this.otr = otr;
        this.maxPoints = maxPoints;
        this.otp = onTimePoints(min, max, maxPoints, otr);
        ...
    }
    var lifeDataInstance = new lifeData(25000, 65000, 56426, 100);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It looks like I was not the only one trying to avoid javascript altogether
I'm trying to set a JavaScript object in my main view: <script type=text/javascript> xx.yy.zz
I am trying to set the margin of an object from JavaScript. I am
I'm trying to set some javascript data (json) in my markup by calling a
I'm trying to set the scroll with jQuery / JavaScript. I'm having trouble figuring
Is this possible in javascript? I'm trying to set the property name of an
I am trying to use JavaScript to set an elements width relative to their
I am having a javascript problem. What I am trying to do is set
Trying to set up a self signed certificate, for our intranet's web services site.
Trying to set it so if a certain condition is met then one of

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.