Modo entrevista. Temporizador de 4 min, sin pistas y sin autocompletado
Static method
FácilClasses4 min
Write a class Person. The constructor takes a first name and a last name. If they are not given, use 'John' and 'Doe'. The method sayFullName() returns the first and last name with a space between them.
Also add a static method greetExtraTerrestrials(raceName). It returns the string 'Welcome to Planet Earth ' with the race name at the end.
Ejemplos
new Person().sayFullName()Devuelve 'John Doe'
new Person('Jane', 'Smith').sayFullName()Devuelve 'Jane Smith'
Person.greetExtraTerrestrials('Martians')Devuelve 'Welcome to Planet Earth Martians'
Cargando el editor…
- Default name
- Name from the arguments
- The greeting is called on the class
Las pruebas ocultas se ejecutan al enviar