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

164
Views
Values Identical but not equal

Image of my array valuesI have a function to "Wed 12/8" and "Wed 12/8". However, when I use them in this function they are not equal for some reason yet they are identical. The function does not append and acts as if they are completely different.

function filterDate() {
  for (var i = 0; i < dateList.length; i++) {
    if(dateList[i] == today) {
      appendItem(filteredDate, dateList[i]);
      appendItem(filteredID, stateID[i]);
      appendItem(filteredCase, totalCases[i]);
      appendItem(filteredState, usState[i]);
    }
  }
}

Here the get date code.

//Date
var now = new Date();

//Gets the current days date
var days = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
var months = ['1','2','3','4','5','6','7','8','9','10','11','12'];
var weekday = days[now.getDay() - 1];
var day = now.getDate() - 1;
var month = months[now.getMonth()];
var today = weekday + " " + month + "/" + day;

//Console logs todays date
console.log(today);

The values are the exact same but the computer thinks they are not. When I manually change today to "Wed 12/8" it works but the variable seems to mess it up though I may be wrong. What's happening and how do I fix this as it is crucial to my program?

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

0

The problem should be the way you populate the dateList array. Are you sure it gets filled with strings too, and not for example date objects? The code you provided does not show anything related to that array.

Edit: Based on the image you provided later, I think the issue will be that your strings in the array contain quotation marks.

Remove them from the strings. (For example by slicing the first and last characters from it in the filterDate function)

function filterDate() {
  for (var i = 0; i < dateList.length; i++) {
    if(dateList[i].slice(1,-1) == today) {
      appendItem(filteredDate, dateList[i]);
      appendItem(filteredID, stateID[i]);
      appendItem(filteredCase, totalCases[i]);
      appendItem(filteredState, usState[i]);
    }
  }
}
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!