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

273
Views
Browser can't process the code, how can I fix it?

i've been trying to take an array and use it to find the largest area in it (using array as height and length between array variables as width) but when i try to launch it the page simply won't load, how can i fix it?

var array = [1, 8, 6, 2, 5, 4, 8, 3, 7];

var height, width, area; var maxArea = 0;

function largestArea () {

for (i = 0; i < array.length; i++){

    for (n = i+1; n = array.length - 2; n++) {

        if (array[i] > array[n]) {
            height = array[n];
        }
        else if (array[i] = array[n]) {
            height = array[n];
        }
        else {
            height = array[i];
        }

        width = n - i;
        area = height * width;

        if (area > maxArea) {
            maxArea = area;
        }
    }
}

console.log(maxArea);

}

largestArea();

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

0

The issue may be because you accidentally assigned n twice instead of using comparison as I think is want you really wanted:

for (n = i+1; n = array.length - 2; n++) {

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!