Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

154
Views
Problem with calling a method using a prototype

Hi I have this code written and I want the output to be "bill jones is a snowboarder of beginner skill on the slopes.". I am getting "function () { return this.firstName + " " + this.lastName; } is a snowboarder of beginner skill on the slopes." I think the problem is the way I am calling the fullName method but I am stuck.

https://codepen.io/stefan927/pen/yLPJdQG?editors=1111

(function() {
  const fullName = document.getElementById('fullName');
  const type = document.getElementById('type');
  const ability = document.getElementById('ability');

  function Person(firstname, lastname, type, ability) {
    this.firstName = firstname;
    this.lastName = lastname;
    this.type = type;
    this.ability = ability;
  }
  Person.prototype.fullName = function() {
    return this.firstName + " " + this.lastName;
  }

  var skier = new Person('Bill', 'Jones', 'snowboarder', 'beginner');


  fullName.textContent = skier.fullName;
  type.textContent = skier.type;
  ability.textContent = skier.ability;

}())
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Like Pointy pointed ( no pun intended ) out in his comment, you are not calling the fullName function which is invoked with a pair of (). So, in your code fullName.textContent = skier.fullName should be fullName.textContent = skier.fullName(). That should resolve your issue.

about 4 years ago · Juan Pablo Isaza Report

0

You have added fullName to the Persons prototype, and it's a function.
So you need to call/invoke this function.

fullName.textContent = skier.fullName(); //added () to fullName
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!