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

130
Views
cómo hacer que la salida sea "¡Negativa!" en console.log(pregunta4([-1, 4, 7, 11]))
function question4(angka){ var w=0 , jml=0, rtt=0; var nilai; nilai=angka; for(w=0;w < nilai.length;w++) { jml=jml+nilai[w]; } rtt=jml/nilai.length; console.log(rtt); } console.log(question4([4, 5, 6, 7, 8])); console.log(question4([100, 200, 300, 400, 500])); console.log(question4([-1, 4, 7, 11]));

Si hay uno o más elementos de matriz con valores negativos, entonces la función genera directamente el texto '¡Negativo!'.

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

0

En primer lugar, no return que llamar a la question4() question4() de una console.log() if (nilai[w] < 0) console.log('Negative!')

about 4 years ago · Juan Pablo Isaza Report

0

Tal vez puedas usar esto

 function hasArrayNegativeValue(valueArray){ for(i=0;i < valueArray.length;i++) { if(valueArray[i] < 0){ return 'Negative'; } } return null; } console.log(hasArrayNegativeValue([4, 5, 6, 7, 8])); console.log(hasArrayNegativeValue([100, 200, 300, 400, 500])); console.log(hasArrayNegativeValue([-1, 4, 7, 11]));
about 4 years ago · Juan Pablo Isaza Report

0

es muy fácil, la función question4 debe devolver un valor.

 function question4(angka){ for(w=0;w < angka.length;w++) { if(angka[w]<0) { return "Negative"; } } return "Posetive"; }
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!