JSFiddle - React, Tailwind, and code Playground

JavaScript

var Obj1 = function (){
    this.getResult = function() {
        var result = 5*5;
        return result;
     };
    
    this.answer = this.getResult();
};

var Obj2 = function(obj1) {
    //assign the answer to this.x, var doesn't 'live' outside of the constructor
    this.x = obj1.answer;
};

//you make an instance of obj1, this is different from the 'class' Obj1
var testobj1 = new Obj1();

//then you pass that instance into an Obj2, so it can be consumed
var testobj2 = new Obj2(testobj1);

console.log(testobj2.x);