Substrings Programming - Basic I am stuk


Find the 4th up to and including the 7th letter of the string "wonderful day".

// Be careful with the substring's letter positions!

I am getting this error

Oops, try again. Did you remember to take your .substring() from the string 'wonderful day'? Make sure to type your string exactly as shown!


Look at this:

"wondrfulday"  "wonderful day"



The substring method extracts the characters in a string between "start" and "end", not including "end" itself. Meaning that in order to include the 7th letter you would need to end the substring with 8.

"wondrfulday".substring(4,8); // "rful"

If, as @cadecodes and the error message suggests the code should be:

"wonderful day".substring(4,8); // "erfu"