I have done this exercise but something tells me that I did not do it well, can you take a look at it and tell me if it is okay or what was your solution? I was a bit confused because I speak Spanish and the translation was a bit confusing to carry out the exercise.
Strings 2
In this task you are provided with two variables, quote
and substring
, which contain two strings. We would like you to:
- Retrieve the length of the quote, and store it in a variable called
quoteLength
. - Find the index position where
substring
appears inquote
, and store that value in a variable calledindex
. - 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
.
let quote = āI do not like green eggs and ham. I do not like them, Sam-I-Am.ā;
let substring = āgreen eggs and hamā;// Add your code here
let quoteLength= quote.length;
let index= 33;
let revisedQuote=I do not like ${substring}
// Donāt edit the code below here!section.innerHTML = ā ';
let para1 = document.createElement(āpā);
para1.textContent =The quote is ${ quoteLength } characters long.
;
let para2 = document.createElement(āpā);
para2.textContent = revisedQuote;section.appendChild(para1);
section.appendChild(para2);