Tell us what’s happening:
I console.log the str.substring(target) but it output the whole string instead of just the. target. I am trying to check why my else statement isn’t working. what is it I am doing wrong/missing?
I read it and from my understanding this is what it does . It takes the starting index and end index (not included in the result) e.g. mahassan.substring(0,2) will return ma ?
so the if statement says "if it is true then return true otherwise return false
If i do console.log(str.substring(target).length) it return a number but we don’t need a number, we need the word so target would return the word. Am I missing something?
You can only pass a number into substring. The variable target is a string, not a number. Therefore, you cannot get meaningful results by passing target into substring.
That’s right, @JeremyLT. I would recommend you, @mahassan, to use .indexOf() to find out what the index of the second argument is and then use that value as a parameter to .substring (). It is a way to do this.