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

206
Views
Mi código pasa todas mis pruebas, pero de alguna manera edabit no lo aprueba
function bitwiseAND(n1, n2) { let a = n1.toString(2).padStart(8, "0"); let b = n2.toString(2).padStart(8, "0"); let x = ""; for (let i = 0; i < 8; i++) { if (+a[i] === 1 && +a[i] === +b[i]) x = x + "1"; else x = x + "0"; } return +x } function bitwiseOR(n1, n2) { let a = n1.toString(2).padStart(8, "0"); let b = n2.toString(2).padStart(8, "0"); let x = ""; for (let i = 0; i < 8; i++) { if (+a[i] === 1 || +b[i] === 1) x = x + "1"; else x = x + "0"; } return +x } function bitwiseXOR(n1, n2) { let a = n1.toString(2).padStart(8, "0"); let b = n2.toString(2).padStart(8, "0"); let x = ""; for (let i = 0; i < 8; i++) { if ((+a[i] === 1 && +b[i] === 0) || (+a[i] === 0 && +b[i] === 1)) x = x + "1"; else x = x + "0"; } return +x }

este es el link del reto

El desafío era escribir tres funciones para calcular el AND bit a bit, el OR bit a bit y el XOR bit a bit de dos números.

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

0

Su código es bueno, lo único que falta es convertir el binario a un número entero en sus valores de retorno.

en lugar de

 return +x

Probar

 return parseInt(x, 2)
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!