Code Lab

The info property

EasyClasses3 min

Write a class Person. The constructor takes a name and an age. The getter info returns a string like 'johns age is 34'.

Examples

new Person('john', 34).info

Returns 'johns age is 34'

It is a property, no parentheses after info.

Source

Loading the editor...
  1. The info string
  2. info is declared with get

Hidden tests run on Submit.