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

299
Views
how can i solve javascript variable error ? (let)
function solution(string, searchValue) {
   let answer;

      for (let i = 0; i < string.length; i++) {
      
      var count_no_string = 0;
      
      //case 1
      if (searchValue[0] == string[i]) {
         let save = i; 
         let count = 0;
         for (let j = 0; j < searchValue.length; j++) { 
            if (searchValue[j] == string[save + j]) {
               count = count + 1;
               if (searchValue.length == count) {
                  answer = save;
                  return answer;
               } else{
                  console.log('f'+ count +' '+ searchValue.length);  
               }
            } else {
               console.log('일치하는 문서가 없습니다'  );
               return -1;
            }
         }
      }
      //case2
      else if(searchValue[0] != string[i]){
         count_no_string = count_no_string+1;
         console.log('test ' + count_no_string);
         
         if(count_no_string == string.length){
            //retrun -1;
            return -1;
         }
         
      }
   }
}

i don't know why count_no_string variable is always '1' why?..

i found let, var, const js variable concept, but i can't solve it

thanks you so much

......... ......... ....... .........

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!