@mikoMK
thank you for the assessment.
about your bonus question - I first treated the substring as index, and then used index to slice it to the start of the original quote.
Sorry I don’t understand your answer. Maybe I asked the question wrong. Let’s try again!
You could replace your code
const name = quote.slice('',index)
const revisedQuote = `${name} ${substring}.`;
with just const revisedQuote = quote.slice(???); and without using a template string. My bonus question is: “What needs to be written instead of the three question marks to achieve this?”
No worries. Because you solved everything perfectly I thought I ask another question, so you don’t get bored You don’t have to solve it.
This line is part of the loop and gets therefore executed for every element of the array. So let’s look what happens when we are in the first round of the loop:
element is "Ryu"
index is 0
One line above we create newElement. it’s defined as "Ryu (0)"
This means our line myArray[index] = newElement; becomes myArray[0] = "Ryu (0)" in the first round of the loop. So we replace the first element of the array ("Ryu") with a new element "Ryu (0)". This happens for every element of the array. In the end every name in the array is replace with name plus index in parentheses.
Generally, when you are unsure what happens in the code you could always write a value to the console. For example, you could put console.log(myArray[index]); above and below the line to see what happens or just put console.log(myArray); after the line to see how the whole array changes during the loop.