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

147
Views
Obtenga el código javascript y modifíquelo para ejecutar chainable

Quiero cambiar mi código para ejecutar el encadenamiento. este es mi código:

 let stepCount = { step: 0, up() { this.step++; }, down() { this.step--; }, showStep: function () { return this.step; } };

¿Cómo debo cambiarlo? Quiero ejecutar este código para obtener respuesta.

 stepCount.up().up().down().up();
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

solo necesita devolver el objeto actual de cada función como esta

 let stepCount = { step: 0, up() { this.step++; return this; }, down() { this.step--; return this }, showStep() { console.log(this.step) return this; } }; stepCount.up().up().down().showStep().down().showStep();

about 4 years ago · Juan Pablo Isaza Report

0

Esto debería hacer el trabajo:

 class Step { constructor(count) { this.step = count; } up() { this.step++; return this; } down() { this.step--; return this; } } console.log(new Step(5).up().up().step); // 7
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!