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

196
Views
Is there a way to find if an integer occurs in another integer?

For example if two integers A and B are given. Integer A occurs in Integer B at position P then the leftmost position should be returned.

For example,

  • 53 occurs in 1953786 at position 2, so the function should return 2.
  • 78 occurs in 1953786 at position 4 and 7.
  • 57 does not occur in 153786.
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Convert to a string and use indexOf:

function getIndex(num1, num2){
  return String(num1).indexOf(String(num2));
}

console.log(getIndex(1953786, 53))

Alternatively:

function getIndex(num1, num2){
  return "".indexOf.call(num1, num2)
}

console.log(getIndex(1953786, 53))

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!