user9085581
user9085581

Reputation:

console.log is returning the function instead of returning interger

class TransitionComp extends Component{


      Duration = ()=>{
        return Math.floor(Math.random() * Math.floor(3000))
    }


    render(){
        console.log(this.Duration)
        return(

        )
    }
}

The console is returning

ƒ () {
            return Math.floor(Math.random() * Math.floor(3000));
        }

instead of an integer. If I don't use "this", Duration will become undefined.

Upvotes: 0

Views: 48

Answers (1)

Md Johirul Islam
Md Johirul Islam

Reputation: 5162

The correct way to invoke the function is:

console.log(this.Duration());

Upvotes: 2

Related Questions