r/codehs • • Mar 17 '23

help please?

Freshly new to coding and learning javascript first but this question has me stumped. I provided my code below I know it's not correct, but any guidance or help would be appreciated greatly!

  1. Define a function, lettersAfter, that accepts three arguments:
  • haystackA string: The string to be searched
  • needleA string: A character to search for.
  • limitA number: The number of letters after the character to return
  1. lettersAftershould return the letters following the first found occurrence of the search character. The letters returned should be limited to the number of the third argument.

//

// YOUR CODEfunction lettersAfter(){let letters = for (let i = 0 ; i < haystack.length; i++){

let char = haystack[i];

if (char === needle ){

for (let j = 0; j < limit; j++){let innerChar = haystack[i + j + 1 ];   letters += innerChar; }      }return letters;  }  }

3 Upvotes

4 comments sorted by

View all comments

Show parent comment

1

u/Standard-Slip1850 Mar 17 '23

First thank you! I just updated my post, and the picture should be there.