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

218
Views
1.Uncaught SyntaxError: Identifier 'user1' has already been declared . 2 and not return updated values

function creatUser(name, score = 0) {
  let user = {};
  user.name = `Amir`;
  user.score = 0;
  user.increaseScore = function (value = 1) {
    user.score = user.score + value;
    return user.score;
  };
  user.decreaseScore = function (value = 1) {
    user.score = user.score - value;
    return user.score;
  };
  user.changeName = function (name) {
    user.name = name;
    return user.name;
  };
  return user;
}
let user1 = creatUser(`Sameer`, 20);
let user2 = creatUser(`Zoya`);

Blockquote when I access user1 it will go through an error user1 alreay defined and when I access user2 then it will not retrun updated values.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

First of all , the code is working well and secondly you should use class for doing this !

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!