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

120
Views
If statement comparing two array values not completing when it should be

I have an array that i have made have two of the same value, i have made a function to check the array for duplicates but for some reason it never goes into the if statement. ( if(array[i] == array[j]) ).

when i is 0 and j is 1 they should be matching.

let sessions = [
    {"title": "Lecture", "sessionTime": new Date(2021, 8, 28, 9), "staff": "example"},
    {"title": "fake", "sessionTime": new Date(2021, 8, 28, 9), "staff": "example"},
    {"title": "Lab 1", "sessionTime": new Date(2021, 8, 28, 14), "staff": "example"},
    {"title": "Lab 2", "sessionTime": new Date(2021, 9, 1, 11), "staff": "example"}
];

errorCheck1 = function(sessions) {
    for (let i = 0; i < sessions.length; i++) {
        for (let j = 0; j < sessions.length; j++) {
            if (i != j) {
                if (sessions[i].sessionTime == sessions[j].sessionTime) {
                    $("#errors").append("<li>" + sessions[i].title + " clashes with " + sessions[j].title +"</li>");
                }
            }
        }
    }
}
about 4 years ago · Juan Pablo Isaza
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!