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

189
Views
TypeError: x.include is not a function

I'm new on JS. In this code country is variable. Results can contain multiple answers at the same time 53,110,122 etc. And for example if I results have 68 I should get it but I get this error: Uncaught TypeError: country.include is not a function

var country         = 68;
if (country.includes(68)) {
var country         = 3;
}
if (country.includes(53)) {
var country         = 138;
}

In Python we can do this with if "x" in country . Any ideas for JS?

Note: If results have 68 and 53 same time, code working.

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

0

includes is a function built-in for arrays. You can use this function with Arrays only or with "values of an Object" which are also an array. Before applying this function to your array which is "country", You have to confirm that whether it is array or not. for that we have a built-in function with Arrays as Array.isArray(country). This function returns true if the provided parameter is an array and vice versa. if(Array.isArray(country)) {... your checking conditions here} Here is simple exercise for include from w3school. Might be helpful. Thanks

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!