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

110
Views
Una función que toma una línea de JavaScript y devuelve un posible comentario de línea recortado

Si la línea no contiene ningún comentario de línea, se debe devolver un valor nulo.

cutComment('let foo; // bar') debería devolver 'bar', pero está devolviendo 'let foo; // bar'.

 function cutComment(comment) { if (comment === null) { return null; } else { return comment.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g, '').trim(); } } console.log(cutComment('let foo; // bar'));

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

0

cambió la expresión regular para que coincida con todo lo que viene después //

 function cutComment(comment) { if(!comment) return null let match = comment.match(/(?<=\/\/).+/) if(match.length > 0 ) { return match[0] }else{ return null } } console.log(cutComment('let foo; // bar'));

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!