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);