+ 1

Trying simple code, pls help

Can't find what's the problem while coding this: https://code.sololearn.com/WBsFI4auVvN4/?ref=app Update: code's been updated , works now ☝️

10th May 2020, 1:14 PM
Shamil
Shamil - avatar
6 Antworten
+ 1
Justus calculateAge is a function if we do this.age = calculateAge() we are assigning a number to this.age if we do this.age = calculateAge we are assigning a function to this.age see?
10th May 2020, 2:18 PM
Gordon
Gordon - avatar
+ 2
This.age = calculateage You forgot to add () to make it a method this.age =calculateage()
10th May 2020, 1:18 PM
Justus
Justus - avatar
0
Thanks . But guys, do you know why in the another code there are no brackets and it still works https://code.sololearn.com/WT2HqEp117QH/?ref=app
10th May 2020, 1:48 PM
Shamil
Shamil - avatar
0
In the first example "bouncy", you executing the function and calculated a value to store in this.age In the second example "bouncer works", you are assigning a function to this.age as class method https://code.sololearn.com/W8p2a2xg3W5w/?ref=app and so later, you call the age method with p.age() at your line 16 to execute it.
10th May 2020, 1:51 PM
Gordon
Gordon - avatar
0
Gordon that line runs without the parenthesis too. But printing the value without the parenthesis won't work. Any explanation..
10th May 2020, 1:56 PM
Justus
Justus - avatar
0
Keep coding , trying with if ..else , so error , anyone? https://code.sololearn.com/WBsFI4auVvN4/?ref=app
10th May 2020, 2:44 PM
Shamil
Shamil - avatar