Help needed for Strings 2

I can’t seem to figure out how to do Step 3 of the Strings 2 test… help!

  1. Retrieve the length of the quote, and store it in a variable called quoteLength .
  2. Find the index position where substring appears in quote , and store that value in a variable called index .
  3. Use a combination of the variables you have and available string properties/methods to trim down the original quote to “I do not like green eggs and ham.”, and store it in a variable called revisedQuote .

Hi @cindoor!

Let’s give you some clues.

So you want to “slice” the quote to discard the part after the first full stop. Your index variable gives you the postition of the start of the substring. You could get the length of the substring from substring.length.

Could you use a combination of theese things to work out the index value to slice to, so it slices past the end of the substring? In fact you need to slice to the full stop after it, so you’ll have to add one more.

okay, after a lot of trial and error, I think I got it thanks to your help!

@cindoor perfect, well done!

1 Like